Hi,
Here is a line from my audit.log file
"type=CRED_DISP msg=audit(1525254633.039:542208): pid=35761 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:setcred grantors=pam_env,pam_fprintd acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=? res=success'
I would like to parse the above line into key value pairs. Problem is the "msg" field which appears twice. I've used the basic KV filter and got the below output.
{
"message" => "type=CRED_DISP msg=audit(1525254633.039:542208): pid=35761 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:setcred grantors=pam_env,pam_fprintd acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=? res=success'",
"@version" => "1",
"host" => "localhost",
"ses" => "4294967295",
"path" => "/var/log/audit/audit.log",
"type" => "CRED_DISP",
"auid" => "4294967295",
"msg" => [
[0] "audit(1525254633.039:542208):",
[1] "op=PAM:setcred grantors=pam_env,pam_fprintd acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=? res=success"
],
"pid" => "35761",
"uid" => "0",
"@timestamp" => 2018-05-02T09:51:25.626Z
}
Here is my logstash filter:
input {
file {
path => "/var/log/audit/audit.log"
start_position => "beginning"
}
}
filter {
if [path] == "/var/log/audit/audit.log" {
kv {
value_split => "="
}
}
}
output {
if [path] == "/var/log/audit/audit.log" {
stdout { codec => rubydebug }
}
}:
I want output something like below:
{
"message" => "type=CRED_DISP msg=audit(1525254633.039:542208): pid=35761 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:setcred grantors=pam_env,pam_fprintd acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=? res=success'",
"@version" => "1",
"host" => "localhost",
"ses" => "4294967295",
"path" => "/var/log/audit/audit.log",
"type" => "CRED_DISP",
"auid" => "4294967295",
"msg" => "audit(1525254633.039:542208):",
"op" => PAM:setcred2
"grantors" => "pam_env,pam_fprintd"
"acct => ""root""
"exe" => ""/usr/bin/sudo""
"hostname" => "?"
"addr" => "?"
"terminal" => "?"
"res" => "success" ],
"pid" => "35761",
"uid" => "0",
"@timestamp" => 2018-05-02T09:51:25.626Z
}