来自 the docs :
Default value is "logstash-%{+YYYY.MM.dd}"
我想知道 logstash 从哪里获取 YYYY.MM.dd 的信息?是@timestamp 字段吗?如果是这样,是否可以告诉它使用不同的字段(例如@mydate)?
最佳答案
索引YYYY.MM.dd是根据@timestamp时间。
可以引用elasticsearch.rb关于打印 logstash 索引的“event.sprintf”。
index = event.sprintf(@index)
然后就可以研究了event.rb看看 sprintf 做了什么。
t = @data["@timestamp"]
formatter = org.joda.time.format.DateTimeFormat.forPattern(key[1 .. -1])\
.withZone(org.joda.time.DateTimeZone::UTC)
#next org.joda.time.Instant.new(t.tv_sec * 1000 + t.tv_usec / 1000).toDateTime.toString(formatter)
# Invoke a specific Instant constructor to avoid this warning in JRuby
# > ambiguous Java methods found, using org.joda.time.Instant(long)
org.joda.time.Instant.java_class.constructor(Java::long).new_instance(
t.tv_sec * 1000 + t.tv_usec / 1000
).to_java.toDateTime.toString(formatter)
所以,如果你想让索引跟随你自己的字段,你必须修改 event.rb 以使用你自己的字段而不是时间戳。或者您可以将时间戳值更改为您自己的字段时间。
关于elasticsearch - logstash的elasticsearch index date从哪里来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24536908/