Syslog时间戳没有年份?

Sid*_*kha 8 elasticsearch logstash kibana

我正在将我的日志回填到Elasticsearch中.因此,为了按日期的时间戳创建索引,我使用这样的date过滤器:

date {
                "locale" => "en"
                match => ["timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss", "ISO8601"]
                target => "@timestamp"
        }
Run Code Online (Sandbox Code Playgroud)

我正在使用来自syslog的日志,而syslog时间戳格式的doest没有年份:

# Syslog Dates: Month Day HH:MM:SS
SYSLOGTIMESTAMP %{MONTH} +%{MONTHDAY} %{TIME}
Run Code Online (Sandbox Code Playgroud)

因此,在使用日期过滤器之后,创建的索引就像logstash-2015.12.26 是在阅读2014年12月26日的日志.因此,由于时间戳在日志中不可用,所以它默认选择当前年份.

知道如何制作正确的索引吗?

Mag*_*äck 7

如果Joda Time正在解析字符串中没有一年,则Logstash当前默认为Logstash进程启动的年份.请参阅github.com/logstash-plugins/logstash-filter-date bug#3.作为临时解决方法,添加临时过滤器以将正确的年份(2014)附加到时间戳字段的末尾,并调整日期过滤器模式以包括YYYY.

filter {
  mutate {
    replace => ["timestamp", "%{timestamp} 2014"]
  }
  date {
    locale => "en"
    match => ["timestamp",
              "MMM  d HH:mm:ss YYYY",
              "MMM dd HH:mm:ss YYYY",
              "ISO8601"]
  }
}
Run Code Online (Sandbox Code Playgroud)