Hello! I'm looking to pull field values from a pattern defined in /etc/logstash/conf.d/patterns
Background:
I'm pulling pfsense firewall logs into Kibana via Logstash. And for the most part, it works. But it's missing some IPv6 data from the logs. For some reason it just cuts off two of the fields. It seems to stem from this pattern call:
PFSENSE_IP_SPECIFIC_DATA (%{PFSENSE_IPv4_SPECIFIC_DATA}|%{PFSENSE_IPv6_SPECIFIC_DATA})
where further down it defines the ipv4 data and the ipv6 data to parse. Oddly, if I call ONLY the ipv6 data (rather than having it go through the "or" operator), it pulls all the info just fine. Or at least that's the the debugger on http://grokdebug.herokuapp.com/ tells me.
Anyway, I figured I'd do a check for the IP version and split off from there based on "4" or "6" being returned. I'm stuck though, in calling a field from the pattern. I first pull the first part of the log line using:
match => [ "message", "%{PFSENSE_LOG_DATA}" ] which is defined as:
PFSENSE_LOG_DATA (%{INT:rule}),(%{INT:sub_rule}),,(%{INT:tracker}),(%{WORD:iface}),(%{WORD:reason}),(%{WORD:action}),(%{WORD:direction}),(%{INT:ip_ver}),
But if I try to check the value of [PFSENSE_LOG_DATA][ip_ver] things fall apart.
How do I read a value from a provided pattern file?
Here's the logstash filter conf:
filter {
if "pfsense" in [tags] {
grok {
match => [ "message", "%{MONTH} %{MONTHDAY} %{TIME} (?.?): (?.)"]
}
mutate {
replace => [ "message", "%{msg}" ]
}
mutate {
remove_field => [ "msg", "%{MONTH}", "%{MONTHDAY}", "%{TIME}" ]
}
if "filterlog" in [prog] {
grok {
add_tag => [ "firewall" ]
patterns_dir => "/etc/logstash/conf.d/patterns"
match => [ "message", "%{PFSENSE_LOG_DATA}" ]
}
if "4" in [PFSENSE_LOG_DATA][ip_ver] {
grok {
patterns_dir => ["/etc/logstash/conf.d/patterns"]
match => [ "message", "%{PFSENSE_LOG_DATA}%{PFSENSE_IPv4_SPECIFIC_DATA}%{PFSENSE_IP_DATA}%{PFSENSE_PROTOCOL_DATA}",
"message", "%{PFSENSE_LOG_DATA}%{PFSENSE_IPv4_SPECIFIC_DATA_ECN}%{PFSENSE_IP_DATA}%{PFSENSE_PROTOCOL_DATA}" ]
}
else {
grok {
patterns_dir => ["/etc/logstash/conf.d/patterns"]
match => [ "message", "%{PFSENSE_LOG_DATA}%{PFSENSE_IPv6_SPECIFIC_DATA}%{PFSENSE_IP_DATA}%{PFSENSE_PROTOCOL_DATA}",
"message", "%{PFSENSE_LOG_DATA}%{PFSENSE_IPv4_SPECIFIC_DATA_ECN}%{PFSENSE_IP_DATA}%{PFSENSE_PROTOCOL_DATA}" ]
}
}
}
mutate {
lowercase => [ 'proto' ]
}
}
}
}
Thanks in advance!