我是ELK堆栈的新手但是在阅读完文档之后我仍然无法让logstash识别自定义时间
日志看起来像这样
2014-11-30 03:30:01.000118,122.99.34.242,123.56.212.1,44,u,q,NA,0 ? a.root-servers.net A
我的logstash过滤器就是这个
filter {
date {
#2014-11-30 03:30:01.000118,122.99.34.242,123.56.212.1,44,u,q,NA,0 ? a.root-servers.net A
match => ["timestamp" , "YYYY-MM-dd HH:mm:ss"]
locale => "en"
}
}
然而,当我通过日志文件运行此配置文件时,它似乎无法识别我已定义的匹配
{
"message" => "2014-11-30 03:30:01.011895,123.52.36.153,213.55.121.1,55,u,q,NA,0\t? mobile-collector.newrelic.com A\t",
"@version" => "1",
"@timestamp" => "2014-12-03T03:09:49.857Z",
"type" => "syslog",
"host" => "0.0.0.0",
"path" => "/var/log/dns/2014-11-30_0335_dnsparse.log"
}
我正在运行“logstash 1.4.2-modified”
为了完整性,这里是我的整个logstash配置
input {
file {
path => "/var/log/dns/*.log"
type => "dns_parselog"
start_position => beginning
}
}
filter {
date {
#2014-11-30 03:30:01.000118,122.99.34.242,123.56.212.1,44,u,q,NA,0 ? a.root-servers.net A
match => ["timestamp" , "YYYY-MM-dd HH:mm:ss"]
locale => "en"
}
}
output {
elasticsearch {
host => localhost
}
stdout { codec => rubydebug }
}
答案 0 :(得分:1)
您要求日期过滤器解析名为“timestamp”的字段,但没有此类字段。首先将消息中的时间戳提取到单独的字段,然后使用日期过滤器。
filter {
grok {
match => ["message", "%{TIMESTAMP_ISO8601:timestamp}"]
}
date {
match => ["timestamp", "YYYY-MM-dd HH:mm:ss.SSSSSS"]
remove_field => ["timestamp"]
}
}
您需要向grok表达式添加其他模式以提取其他字段,但这不属于此问题的范围。