Created
September 16, 2017 16:05
-
-
Save FrankSpierings/03ac03acfe829872d7f47a0bc522a8d6 to your computer and use it in GitHub Desktop.
ELK indexing iptables messages (UFW)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Add this specific input | |
- input_type: log | |
paths: | |
- /var/log/ufw.log | |
tags: ["iptables"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter { | |
if ("iptables" in [tags]) { | |
grok { | |
break_on_match => true | |
patterns_dir => "/etc/logstash/patterns/ufw" | |
match => { "message" => "%{IPTABLES}" } | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IN IN=(?<nf_in>.*?) | |
OUT OUT=(?<nf_out>.*?) | |
SRC SRC=(?<nf_src>.*?) | |
DST DST=(?<nf_dst>.*?) | |
SPT SPT=(?<nf_spt>.*?) | |
DPT DPT=(?<nf_dpt>.*?) | |
MAC MAC=(?<nf_mac>.*?) | |
PROTO PROTO=(?<nf_proto>TCP|UDP|ICMP|[0-9]+) | |
HEADER (%{SYSLOGTIMESTAMP:nf_timestamp})\s*(%{HOSTNAME:nf_host})\skernel: \[%{INT}\.%{INT}\] | |
NFCOMMENT (?<nf_comment>.*) | |
IPTABLES_TCPUDP %{HEADER} %{NFCOMMENT}%{IN}\s%{OUT}\s%{SRC}\s%{DST}\s.*?%{PROTO}\s.*?%{SPT}.?%{DPT}\s.*?$ | |
IPTABLES_OTHER %{HEADER} %{NFCOMMENT}%{IN}\s%{OUT}\s.*?%{SRC}%{DST}\s.*?%{PROTO}\s | |
IPTABLES (?:%{IPTABLES_TCPUDP}|%{IPTABLES_OTHER}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment