如何在日志中将时间设置为elasticsearch中的主@timestamp

Eit*_*ely 1 elasticsearch logstash kibana logstash-grok

我使用logstash索引弹性数据库中的一些旧日志文件.我需要kibana/elastic来设置日志文件中的时间戳作为主@timestamp.

我以下列方式使用grok过滤器:%{TIMESTAMP_ISO8601:@timestamp}而elasticsearch将索引的时间设置为主@timestamp,而不是在日志行中写入的时间戳.

知道我在这里做错了什么吗?

谢谢

Mag*_*äck 5

使用日期过滤器设置@timestamp字段.将时间戳以其所处的格式提取到单独的(临时)字段中,例如timestamp,并将其提供给日期过滤器.在您的情况下,您很可能能够使用特殊的ISO8601时间戳格式令牌.

filter {
  date {
    match => ["timestamp", "ISO8601"]
    remove_field => ["timestamp"]
  }
}
Run Code Online (Sandbox Code Playgroud)