フィールドの値に基づいてインデックス名にパターンを使用できます。ここでは、インデックスに名前を付けるためにtype
フィールドの値を使用します。
output {
stdout {codec => rubydebug}
elasticsearch {
host => "localhost"
protocol => "http"
index => "%{type}_indexer"
}
}
ます。また、同じESホストまたは異なるESホストにいずれかのいくつかのelasticsearch
出力を使用することができます。
output {
stdout {codec => rubydebug}
elasticsearch {
host => "localhost"
protocol => "http"
index => "trial_indexer"
}
elasticsearch {
host => "localhost"
protocol => "http"
index => "movie_indexer"
}
}
か多分あなたは、いくつかの変数に基づいて、異なる指標へのルートドキュメントをしたい:
output {
stdout {codec => rubydebug}
if [type] == "trial" {
elasticsearch {
host => "localhost"
protocol => "http"
index => "trial_indexer"
}
} else {
elasticsearch {
host => "localhost"
protocol => "http"
index => "movie_indexer"
}
}
}
UPDATE
構文はLogstash 2と5に少し変更されています
output {
stdout {codec => rubydebug}
if [type] == "trial" {
elasticsearch {
hosts => "localhost:9200"
index => "trial_indexer"
}
} else {
elasticsearch {
hosts => "localhost:9200"
index => "movie_indexer"
}
}
}
出典
2015-11-20 06:54:55
Val
を使用すると、「入力」セクションで宣言された「タイプ」を参照していますか?もしそうなら、私はロギングしている実際のredisイベントのフィールドのインデックスの1つとして使用する方法がありますか? – Kepedizer
@Kepedizer 'type'は、入力セクションであろうとフィルタセクションであろうと、どこでも定義することができます。あなたの他の質問(http://stackoverflow.com/questions/41531883/logstash-wont-pass-index-from-redis)の唯一の問題はタイプミスですが、あなたは '%{index}'の代わりに'$ {index} ' – Val
@Val Logstashのドキュメントでこれに対する答えを見つけようと苦労していましたので、どうもありがとうございました。 StackOverflowのために別のスコアを付けます。 –