The goal is to parse a line from syslog and if the program is sshd, parse the extracted message to grab the source IP. My grok line looks like this:
filter {
if [fields][type] == "syslog" {
grok {
match => {
"message" => ["%{SYSLOGTIMESTAMP:[system][syslog][timestamp]} %{SYSLOGHOST:system.syslog.hostname} %{DATA:[system][syslog][program]}(?:\[%{POSINT:[system][syslog][pid]}\])?: %{GREEDYMULTILINE:[system][syslog][message]}"]
}
pattern_definitions => {
"GREEDYMULTILINE"=> "(.|\n)*"
}
remove_field => ["message"]
}
...
}
What I would like to have is something like:
filter {
if [fields][type] == "syslog" {
grok {
match => {
"message" => ["%{SYSLOGTIMESTAMP:[system][syslog][timestamp]} %{SYSLOGHOST:system.syslog.hostname} %{DATA:[system][syslog][program]}(?:\[%{POSINT:[system][syslog][pid]}\])?: %{GREEDYMULTILINE:[system][syslog][message]}"]
}
pattern_definitions => {
"GREEDYMULTILINE"=> "(.|\n)*"
}
remove_field => ["message"]
}
if "system.syslog.program" == "sshd" {
grok {
match => { "[system][syslog][message]" => [ "Disconnected from user root %{IP:[system][auth][ssh][ip]} ", "Accepted keyboard-interactive/pam for root from %{IP:[system][auth][ssh][ip]} " ] }
}
geoip {
source => "system.auth.ssh.ip"
target => "system.auth.ssh.geoip"
}
mutate {
add_tag => [ "auth" ]
}
}
}
}
Is this possible? I've tried it the way described above as well as trying:
if "[system][syslog][program]" == "sshd" {
But I've had no luck with either. Is this even possible to do?