How to construct geo_point field from separate fields of latitude and longitude from Kafka?

How to construct geo_point field in logstash from Kafka input? This is my logstash config file. But Kibana not recognizing as a geo_point field.

input {

kafka {
        bootstrap_servers => "localhost:9095"
        topics => ["ma_readings", "sms_log"]
		decorate_events => true
}

}

filter {

json {
	source => "message"
	remove_field => ["message"]
}

if [@metadata][kafka][topic] == "ma_readings" {
	mutate{
		add_field => { "Location" => ["%{Lat}","%{Lon}"] }        		
		remove_field => ["Lat", "Lon"]
	}
	mutate {
	  convert => { "Location" => "float" }
	}
}

}

output {

elasticsearch {
	hosts => ["https://localhost:9200"]
	index => "%{[@metadata][kafka][topic]}"
	workers => 1
	user => 'logstash_internal2'
	password => 'logstash_internal2'
	ssl_certificate_verification => false

}

"Location": [
6.0181456,
80.71436
]

image

Welcome,

Just a check, but did you assign it the geopoint type in your mapping?
see: Geopoint field type | Elasticsearch Guide [8.7] | Elastic

PUT <index-name>
{
  "mappings": {
    "properties": {
      "Location": {
        "type": "geo_point"
      }
    }
  }
}

And according to the documentation, if you provide the geopoint as an array, the order is lon, lat. So you need to change the order in your filter.
And maybe you need to do the conversion to float before you create the array, but I am not sure.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.