Logstash日期ISO8601转换

时间:2015-12-09 08:10:56

标签: date logstash

我想将logstash日期类型转换为此类型2015-12-03 03:01:00[message][3] - [message][1]

日期匹配不起作用,我该怎么办?

%{[message][0]}表达是否正确。

filter {
    multiline {
       .............
    }
    grok {
        match => { "message" => "%{GREEDYDATA:message}" }
        overwrite => ["message"]
    }
    mutate {
        gsub => ["message", "\n", " "]
        split => ["message", " "]
    }
    date {
        match => [ "%{[message][0]}","ISO8601"} ]
    }
}

消息输出如下:

"message" => [
[0] "2015-12-03T01:33:22+00:00"
[1]
[2]
[3] "2015-12-03T01:33:24+00:00"
]

1 个答案:

答案 0 :(得分:0)

假设您的输入是:

2015-12-03T01:33:22+00:00\n\n2015-12-03T01:33:24+00:00

你可以不分裂地搞定:

match => { message, "%{TIMESTAMP_ISO8601:string1}\\n\\n%{TIMESTAMP_ISO8601:string2}" }

然后,您可以使用带有string1或string2的date {}过滤器作为输入。