Filter for multiple log formats in syslog
Posted: Fri Jan 22, 2021 6:47 am
I've got 2 different log formats coming in over syslog, from the same host and want to set the type field based on the format of the line. I know you can have multiple pattern matches in grok (for example at the end of this page https://coralogix.com/log-analytics-blo ... -examples/) but i want to set a field based on the match.
So for example
if pattern one
'type" = "log 1"
if patter two
'type' = 'log 2'
what's the best way to do that?
my current filter (which was for just one type of log) is
if [type] == 'syslog' {
if [host] == '192.168.10.10' {
grok {
match => [ 'message', "%{TIMESTAMP_ISO8601:timestamp} %{IP:ipaddress} %{USERNAME:action}: %{WORD:username} %{USERNAME:WorkstationName} %{WORD:location}" ]
}
mutate { replace => [ 'type', 'log1']}
mutate { replace => [ 'host', "%{ipaddress}"]}
}
}
thanks
So for example
if pattern one
'type" = "log 1"
if patter two
'type' = 'log 2'
what's the best way to do that?
my current filter (which was for just one type of log) is
if [type] == 'syslog' {
if [host] == '192.168.10.10' {
grok {
match => [ 'message', "%{TIMESTAMP_ISO8601:timestamp} %{IP:ipaddress} %{USERNAME:action}: %{WORD:username} %{USERNAME:WorkstationName} %{WORD:location}" ]
}
mutate { replace => [ 'type', 'log1']}
mutate { replace => [ 'host', "%{ipaddress}"]}
}
}
thanks