【问题标题】:Incorrect @timestamp logstash date filter@timestamp logstash 日期过滤器不正确
【发布时间】:2015-03-12 15:44:22
【问题描述】:

我在 Windows 上使用 Logstash 1.4.2。

我正在从我的日志中解析一个日期时间(字段'timestamp_file'),我尝试将其值影响到字段@timestamp 我正在解析的时间戳示例:2015-03-09 00:35:11,073

    # format date
    date{
        match =>["timestamp_file","YYYY-MM-dd HH:mm:ss,SSS"]
        target => "@timestamp"
        }

但在 Kibana 中,@timestamp 字段的值不同(一小时间隔) kibana 中的示例 timestamp_file = 2015-03-12 15:34:30,580 @timestamp = 2015-03-12T15:34:30.580+01:00

在映射中,ES 将我的字段 timestamp_file 视为字符串而不是日期。 可能是因为这个。

欢迎任何帮助来解决这个问题。

【问题讨论】:

  • Elasticsearch 以 UTC 格式存储日期。你是 UTC+1 吗?
  • 你期望什么输出?
  • AlainCollins 是的,我在 UTC+1。 @BenLim 我希望与我的字段 timestamp_file 具有相同的时间戳,或者如果它在 UTC 中,我可以进行有意义的显示吗?例如 2015-03-12T22:17:24.803+01:00 而不是 2015-03-12T21:17:24.803Z Z 表示 ZULU,但对于用户来说这只是一个小时的间隔!

标签: timestamp logstash datefilter


【解决方案1】:

Kibana 将以 UTC 时间显示该值。因此,如果您想在您的时区显示@timestamp 字段,例如"@timestamp" => "2015-03-09T04:24:29.718+01:00",您必须在过滤器中进行一些转换。

input {
    stdin {}
}

filter {
    ruby {
        code => "event['@timestamp'] = event['@timestamp'].localtime('+01:00')"
    }
}

output {
    stdout {
         codec => rubydebug
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-13
    • 2014-10-20
    • 1970-01-01
    • 2016-05-21
    • 1970-01-01
    • 1970-01-01
    • 2019-10-07
    • 1970-01-01
    相关资源
    最近更新 更多