Last active
August 29, 2015 14:09
-
-
Save sl1pm4t/ac7ff82b9f2e3a5802a6 to your computer and use it in GitHub Desktop.
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
GROK PATTERN | |
AUDIT type=%{WORD:audit_type} msg=audit\(%{NUMBER:audit_epoch}:%{NUMBER:audit_counter}\): argc=(%{NUMBER:audit_argc}) %{GREEDYDATA:audit_raw_args} | |
# Logstash Conf snippet | |
filter { | |
grok { | |
match => { "message" => "%{AUDIT}" } | |
} | |
mutate | |
{ | |
convert => [ "audit_argc", "integer" ] | |
} | |
ruby { | |
code => " | |
if !event['audit_argc'].nil? && event['audit_argc'] > 0 && !event['audit_raw_args'].nil? | |
argc = event['audit_argc'] | |
raw_args = event['audit_raw_args'] | |
event['audit_args'] = '' | |
for i in 0..(argc - 1) | |
arg_key = 'a' + i.to_s | |
arg_match = raw_args.match(arg_key+'=\"(.*?)\"') | |
if !arg_match.nil? | |
event[arg_key] = arg_match.captures[0].to_s | |
event['audit_args'] = event['audit_args'] + ' ' + arg_match.captures[0].to_s | |
end | |
end | |
end" | |
} | |
} | |
# Example input line: | |
# type=EXECVE msg=audit(1415736961.619:352083): argc=4 a0="/bin/bash" a1="/usr/bin/tester" a2="-H" a3="cool" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment