はじめに
- Elasticsearch の検索結果を jq で加工して Logstash のインプットとし、フィルターの動作確認をしたりするのに使ってみる。
Elasticsearch へ検索クエリの実行
curl -XGET 'http://localhost:9200/_search?size=1000' -o out.json
jq で検索結果を加工
cat out.json | jq -c '.hits.hits[]._source' > input.json
Logstash で加工したファイルをインプットに設定して実行
logstash.conf
input {
file {
path => "/path/to/input.json"
codec => "json"
}
}
filter {
if [foo] in "foo" {
mutate { add_tag => "field in string" }
}
}
output {
stdout {
codec => "json"
}
}
logstash -f logstash.conf