Logstash is sending winlogbeat fields to Spunk and when the fields don't exist it is send something like %{[winlog][event_data][AuthenticationPackageName]}
I am trying to find a way to either not send the field if it doesn't exist or at least send something like " - " for the fields that don't exist.
I tried the following scenario:
scenario 1:
filter {
if [agent][type] == "winlogbeat" {
mutate {
add_field => {
"Authentication_package" => "%{[winlog][event_data][AuthenticationPackageName]}"
"Error_Code" => "%{[winlog][event_data][ErrorCode]}"
}
add_tag => [ "winsplunk" ]
}
ruby {
init => "SplunkFields = ['[Authentication_package]','[Elevated_Token]']"
code => "
SplunkFields.each { |k, v|
if v.to_s.start_with?('%') || v =~ '%{['
event.set(k, 'hello')
end
}
"
}
}
}
Not sure how to get this work as there 15 or more fields sending to Splunk and 13 of the have "%{[" based on how many fields exists
scenario 2:
filter {
if [agent][type] == "winlogbeat" {
if ([winlog][event_data][AuthenticationPackageName]) {
mutate {
add_field => {
"Authentication_package" => "%{[winlog][event_data][AuthenticationPackageName]}"
}
}
} else {
mutate {
add_field => {
"Authentication_package" => " - "
}
}
}
}
The problem with this scenario is I have to repeat this approach for 15 fields