I am trying to upload my text file on Elasticsearch using Logstash. Below is how my config file look like. When I upload my text files on elasticsearch, the src_ip and dst_ip fields are by default taken as string type. Can you please tell me how can I convert src_ip and dst_ip field in ip type in filter?
The conversion is not done within Logstash, but as a manually applied Elasticsearch mapping.
This can be done within a template, so that the mapping is automatically applied to each new index created (that matches the pattern). For example, you'd put the lines:
I understand that the conversion doesn't happen within logstash. But I am new to elasticsearch and I don't know other ways of applying mapping to elasticsearch.
Also, can you please tell me more about template? Do I have to create a template? Or it create every time I make new index?
Once a template is in place, all indices matching the name pattern will get that template. There is one that ships with Logstash (the one linked above). I suggest copying that one, and editing it with the lines I recommended.
This will only work if you are using the default logstash-YYYY.MM.dd naming pattern. (If you do not have a custom index => directive in your elasticsearch block, then you are using the default).
i have been searching for his, thanks for the info but unfortunately for new people this is not very useful so i am sharing the whole code to help (used default template in elastic 5.1.2 as template)
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.