忽略登录 grok 的结尾部分
ignore end part of log in grok
我是 grok 和 logstash 的新手,我有一个用 space 分隔的日志文件,像这样
1477879888.908 728 486704579 TCP_REFRESH_UNMODIFIED/304 254 GET http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Index - HIER_DIRECT/91.189.88.162 -
我只想填写这部分的日志,忽略其他部分
1477879888.908 728 486704579 TCP_REFRESH_UNMODIFIED/304 254 GET http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Index
忽略其他部分(我只想要 7 space 分隔数据并忽略其他数据
你可以使用这个 grok 模式。
%{BASE10NUM:number1}%{SPACE}%{INT:number2}%{SPACE}%{INT:number3}%{SPACE}%{WORD:msg}/%{INT:number4}%{SPACE}%{INT:number5}%{SPACE}%{WORD:protocol}%{SPACE}%{URI:action}
输入
1477879888.908 728 486704579 TCP_REFRESH_UNMODIFIED/304 254 GET http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Index - HIER_DIRECT/91.189.88.162 -
输出
number1 477879888.908
number2 728
port
number5 254
number4 304
msg TCP_REFRESH_UNMODIFIED
action http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Index
protocol GET
number3 486704579
然后您可以合并 msg
和 number4
以获得新字段 tcpMsg
。最后删除 msg
、number4
和 port
.
mutate {
add_field => {
"tcpMsg" => "%{msg}/%{number4}"
}
remove_field => ["msg", "number4","port"]
}
希望对您有所帮助。
我是 grok 和 logstash 的新手,我有一个用 space 分隔的日志文件,像这样
1477879888.908 728 486704579 TCP_REFRESH_UNMODIFIED/304 254 GET http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Index - HIER_DIRECT/91.189.88.162 -
我只想填写这部分的日志,忽略其他部分
1477879888.908 728 486704579 TCP_REFRESH_UNMODIFIED/304 254 GET http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Index
忽略其他部分(我只想要 7 space 分隔数据并忽略其他数据
你可以使用这个 grok 模式。
%{BASE10NUM:number1}%{SPACE}%{INT:number2}%{SPACE}%{INT:number3}%{SPACE}%{WORD:msg}/%{INT:number4}%{SPACE}%{INT:number5}%{SPACE}%{WORD:protocol}%{SPACE}%{URI:action}
输入
1477879888.908 728 486704579 TCP_REFRESH_UNMODIFIED/304 254 GET http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Index - HIER_DIRECT/91.189.88.162 -
输出
number1 477879888.908
number2 728
port
number5 254
number4 304
msg TCP_REFRESH_UNMODIFIED
action http://security.ubuntu.com/ubuntu/dists/precise-security/main/i18n/Index
protocol GET
number3 486704579
然后您可以合并 msg
和 number4
以获得新字段 tcpMsg
。最后删除 msg
、number4
和 port
.
mutate {
add_field => {
"tcpMsg" => "%{msg}/%{number4}"
}
remove_field => ["msg", "number4","port"]
}
希望对您有所帮助。