Grok,解析iPtables远程日志
我是Grok的新手,以前从未与Grok合作,但是现在,我需要帮助。 我有来自远程系统的远程日志消息,其中包含iPtables规则。
May 11 09:37:05 zabbix kernel: [1607613.428683] FW_F_IN_DROP: IN=ens18 OUT= MAC=3a:e9:5f:c7:41:78:d0:07:ca:8c:10:01:08 :00 src = 104.16.55.12 dst = 9.0.20.11 len = 40 tos = 0x00 prec = 0x00 ttl = 243 id = 36679 proto = 36679 proto = tcp spt = 58399 dpt = 58399 dpt = 8427窗口= 8427窗口= 1024
我找到了一个规则: (((%{syslogtimestamp:nf_timestamp}))\ s*(%{hostName:nf_host})\ s*kernel \ s+s+s+s+\ s*(%{word:nf_action})? nf_in_interface})?。 )。*dst =(%{ipv4:nf_dst_ip})。*proto =(%{word:nf_protocol})。?*spt =(%{int:nf_src_port}? *))
我喜欢此规则,但是此规则的输出不包含来自iptables的字符串: -J log -log-prefix“我的日志前缀”
在这种情况下等于:fw_f_in_drop
也是什么,什么是解析的最佳解决方案:[1607613.428683],看起来这是一个内核PID,但还包括在中间点
可以帮助我修改此规则以还包括日志prefix,也可以帮助我修改此规则。信息。
谢谢。
I am new with grok and haven't work with grok before, but now, I need a help.
I have remote log message from remote system which contains iptables rules.
May 11 09:37:05 zabbix kernel: [1607613.428683] FW_F_IN_DROP: IN=ens18 OUT= MAC=3a:e9:5f:c7:41:78:d0:07:ca:8c:10:01:08:00 SRC=104.16.55.12 DST=9.0.20.11 LEN=40 TOS=0x00 PREC=0x00 TTL=243 ID=36679 PROTO=TCP SPT=58399 DPT=8427 WINDOW=1024 RES=0x00 SYN URGP=0
I found a rule:((%{SYSLOGTIMESTAMP:nf_timestamp})\s*(%{HOSTNAME:nf_host})\s*kernel\S+\s*(%{WORD:nf_action})?.*IN=(%{USERNAME:nf_in_interface})?.*OUT=(%{USERNAME:nf_out_interface})?.*MAC=(%{COMMONMAC:nf_dst_mac}):(%{COMMONMAC:nf_src_mac})?.*SRC=(%{IPV4:nf_src_ip}).*DST=(%{IPV4:nf_dst_ip}).*PROTO=(%{WORD:nf_protocol}).?*SPT=(%{INT:nf_src_port}?.*DPT=%{INT:nf_dst_port}?.*))
I like this rule, but output of this rule doesn't contain a string from iptables:-j LOG --log-prefix "my log prefix"
which in this case equal to: FW_F_IN_DROP
also, what is the best solution to parse: [1607613.428683], looks like this is a kernel pid, but included also point in the middle
Can someone help me to modify this rule to include also log prefix information.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
%{word:log_prefix}的图案中的其他单词:
修改过的过滤器看起来像这样:
日志的解析将添加以下字段:
You grab an additional word in your pattern with
%{WORD:log_prefix}:
The modified filter would look like this:
The parsing of your log will add the following field: