【发布时间】:2014-09-23 10:16:53
【问题描述】:
我是 Logstash、elasticsearch 的新手。
我有 NodeJS 应用程序,我通过 Winston:Redis 发送日志。我有不同类型的日志,例如请求、系统等。我希望这些日志位于 ElasticSearch 内的单独 index_type 中。
我正在发送这些密钥 fe。 : "web:production:request", "web:production:system" 和我发送 JSON 对象。
我的配置是:
NodeJS(Winston Redis 客户端)-> Redis -> Logstash -> 弹性搜索
它工作得很好,除了 index_types。
我有 1 个 redis 客户端(流/订阅),我想根据弹性搜索输出中不同 index_types 的键值过滤这些日志。
我试过这个配置:
input {
redis {
host => "127.0.0.1"
data_type => "pattern_channel"
key => "web:production:*"
codec => json
}
filter {
if [key] == "web:production:request" {
alter {
add_field => { "index_type" => "request" }
}
}
if [key] == "web:production:system" {
alter {
add_field => { "index_type" => "system" }
}
}
}
output {
elasticsearch {
index => "web-production-%{+YYYY.MM.dd}"
index_type => "%{index_type}"
# THIS IS NOT WORKING
protocol => "http"
}
}
所以问题是:
条件句如何正确?
如果您想根据条件发送不同的索引,您将如何进行
我不能在命令中设置条件?费。 grok { if [key] == "1" {} } ?
【问题讨论】:
-
它在 ES 中插入了什么或者你得到了某种错误?
标签: elasticsearch conditional logstash