elasticsearch 日志隐藏@timestamp有问题
我在笔记本电脑上设置了ELK,时间戳字段有问题。 我的输入文件如下所示。。。(到目前为止只有一行) 我的代码如下所示elasticsearch 日志隐藏@timestamp有问题,elasticsearch,logstash,logstash-grok,elasticsearch,Logstash,Logstash Grok,我在笔记本电脑上设置了ELK,时间戳字段有问题。 我的输入文件如下所示。。。(到目前为止只有一行) 我的代码如下所示 input { file { path => "/usr/local/bin/firewall_log" } } filter { grok { match => {"message", "%{WORD:type} %{NUMBER:nums} %{IP:sourceip} %{WORD:Action}"} add_tag =>
input {
file {
path => "/usr/local/bin/firewall_log"
}
}
filter {
grok {
match => {"message", "%{WORD:type} %{NUMBER:nums} %{IP:sourceip} %{WORD:Action}"}
add_tag => "checkpoint"
}
date {
match => {"DATETIME" => "%{dd mmm yyyy hh:mm:ss}"}
target => "@timestamp"
}
}
output {
elasticsearch { host => localhost }
当我运行它时,我得到以下结果
"message" => "Chckpoint 502 10.189.7.138 Allow 18 Mar 2015 15:00:01 ",
"@version" => "1",
"@timestamp" => "2015-04-30T19:02:21.663Z",
"host" => "UOD-220076",
"path" => "/usr/local/bin/firewall_log",
"type" => "Chckpoint",
"nums" => "502",
"sourceip" => "10.189.7.138",
"Action" => "Allow",
"tags" => [
[0] "checkpoint"
这很好,除了时间戳-它显示今天的日期,但我想让它做的是将时间戳设置为日志文件中的内容,在本例中为2015年3月18日15:00:01。
请帮助。如果您提供正确的信息,日期{}过滤器将为您提供帮助 首先,为时间戳定义自定义模式:
MYTIMESTAMP %{MONTHDAY} %{MONTH} %{YEAR} %{TIME}
然后将其添加到grok模式中,这样就可以得到一个新字段:
%{WORD:type} %{NUMBER:nums} %{IP:sourceip} %{WORD:Action} %{MYTIMESTAMP:mytime}
然后可以将mytime变量传递给日期筛选器:
date {
match => {"mytime" => "dd MM YYYY HH:mm:ss"}
}
date {
match => {"mytime" => "dd MM YYYY HH:mm:ss"}
}