Export data from Elasticsearch to CSV using Logstash

醉酒当歌 提交于 2019-12-12 09:59:17

问题


How can I export data from Elasticsearch to CSV using Logstash? I need to include only specific columns.


回答1:


Install 2 plugins: elasticsearch input plugin and csv output plugin. Then create a configuration file. Here is a good example for this particular case.

You are ready to go now, just run:
bin/logstash -f /path/to/logstash-es-to-csv-example.conf

And check export.csv file specified in output -> csv -> path.




回答2:


Important note: There is a known bug in csv output plugin when working with Logstash 5.x. The plugin generates a string of %{host} %{message}%{host} %{message}%{host} %{message}. There's an open issue for it: https://github.com/logstash-plugins/logstash-output-csv/issues/10

As a workaround you may:

  • downgrade to Logstash 2.x until this gets resolved
  • use the file output instead

    file {
        codec => line { format => "%{field1},%{field2}"}
        path => "/path/to/data_export.csv"
    }
    
  • modify the plugin's code according to the github discussion...



来源:https://stackoverflow.com/questions/37007206/export-data-from-elasticsearch-to-csv-using-logstash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!