Logstash日期解析失败,自纪元以来以毫秒为单位

时间:2017-07-24 08:55:56

标签: date parsing logstash

Logstash无法解析自epoch以来的毫秒数并返回解析失败。 xml中timestamo字段的内容中没有whitspace,logstash选择正确的值。

<ul>
  <li><span>Charlie three</span><span class="myButtons"><button class="update">Update</button><button class="remove">Remove</button></span></li>
  <li><span>Bravo two</span><span class="myButtons"><button class="update">Update</button><button class="remove">Remove</button></span></li>
  <li><span>newuser</span><span class="myButtons"><button class="update">Update</button><button class="remove">Remove</button></span></li>
  <li><span>Golf</span><span class="myButtons"><button class="update">Update</button><button class="remove">Remove</button></span></li>
</ul>

我做错了什么?

修改

示例xml数据行:

filter {
    xml {
            source => "message"
            remove_namespaces => true
            store_xml => false
            xpath => ["//event/@timestamp", "@time_since_epoch"]
    }

    date {
            match => [ "@time_since_epoch","UNIX_MS" ]
            target => "@time"
    }
}

1 个答案:

答案 0 :(得分:1)

显然,从xpath中提取的值放在一个数组中(参见:"@time_since_epoch":["1494599590213"],带有stdout插件和json编解码器)。

所以你需要以数组元素的形式访问时间:

date {
        match => [ "[@time_since_epoch][0]","UNIX_MS" ]
        target => "@time"
}