how to add geo_point type data to elasticsearch from logstash?

1.7k views Asked by At

I would like to add some custom geo search functions to my program(not geoip, translating ip address into coordinate). How do i filter custom lat and lng data into elasticsearch geo_type format data so that i can visualize in kibana tile map?

1

There are 1 answers

0
daTokenizer On

so as you may have found out, there is a (somewhat clunky) solution. basically you need to set the mapping of the geo_point field before you could log data that way (I also used ES python module directly instead logging via logstash.. just to be sure).

so how do you set the correct mapping?

  1. make sure you use a fresh instance of elasticsearch (or at least that the mapping for both the index and the type you will use is not set yet)

  2. run from sense (or use the appropriate curl command)

PUT <index_name> { "mappings": { "<type_name>": { "properties": { "timestamp": { "type": "date" }, "message": { "type": "string" }, "location": { "type": "geo_point" } <etc.> } } } }

now you're golden, just make sure that your geo_points are in a format that ES excepts

more on mapping geo_points here:

ElasticSearch how to setup geo_point

and here:

https://discuss.elastic.co/t/geo-point-logging-from-python-to-elasticsearch/37336