我有以下类型的 json,使用 filebeat {"@timestamp":"2017-02-10T06:30:51.424Z","beat":{"hostname":"myhostname","name":"mydevice-logger","version":"5.2.0"},"fields":{"device_type":"mydevice","env":"staging"}, "metricset":{"module":"system","name":"cpu","rtt":211},"system":{"cpu":{"cores":4,"idle":{"pct":0.000000},"iowait":{"pct":0.000000},"irq":{"pct":0.000000},"nice":{"pct":0.000000},"softirq":{"pct":0.000000},“窃取”:{“pct”:0.000000},“系统”:{“pct”:0.000000},“用户”:{“pct”:0.000000}}},“标签”:[“自动机” "box"],"type":"metricbeat-test-log"
我的 logstash(版本 5.1.1)配置包含如下所示的输入、过滤器和输出 -
input {
beats {
port => 5046
codec => json
}
}
filter {
if ...{}
else if [type] == "metricbeat-test-log" {
date {
match => ["@timestamp", "ISO8601"]
}
}
}
}
output {
if ...{}
else if [type] == "metricbeat-test-log" {
stdout { codec => rubydebug }
}
}
类型正确,但日期过滤器不起作用。 @timestamp
最终始终采用当前时间戳。我想用 json 中的原始 @timestamp
替换它。
最佳答案
您应该在日期过滤器中使用目标设置:
来自 https://www.elastic.co/guide/en/logstash/5.1/plugins-filters-date.html#plugins-filters-date-target
目标
值类型为字符串
默认值为“@timestamp”
将匹配的时间戳存储到给定的目标字段中。如果未提供,则默认更新事件的@timestamp 字段。
关于elasticsearch - 如何覆盖来自 logstash 中的 json 的时间戳字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42200481/