【发布时间】:2016-02-21 08:47:34
【问题描述】:
我打算设置一个 ELK 堆栈设置,其中每日 JSON 输入存储在创建的日志文件中,每个日期一个。我的 logstash 将通过这些日志侦听输入,并将其存储到 Elasticsearch 中与日志文件条目日期相对应的索引处。
我的logstash-output.conf 类似于:
output {
elasticsearch {
host => localhost
cluster => "elasticsearch_prod"
index => "test"
}
}
因此,就目前而言,logstash 的所有输入都存储在 elasticsearch 的索引 test 中。我想要的是在 2015.11.19 上发生的 logstash 条目,它存储在名为 logstash-2015.11.19.log 的日志文件中,必须相应地存储在索引 test-2015.11.19 中。
我应该如何编辑我的 logstash 配置文件来启用它?
【问题讨论】:
-
需要附加通配符,例如:index => "test-%{+YYYY.MM.dd}"
-
@pandaadb 感谢您的快速回复。有没有办法从日志文件名中获取时间戳,而不是使用系统时间戳?
-
你可以有效地使用正则表达式,所以我们可以在这个url grokconstructor.appspot.com/do/match进行所有这些测试
-
@AnilkumarBathula 这是一个方便的链接...谢谢 :)
标签: elasticsearch logstash logstash-configuration