LoginSignup
1
0

More than 5 years have passed since last update.

Elasticsearch の検索結果を加工して Logstash のインプットにする

Posted at

はじめに

  • 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
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0