So I have my data being parsed , transformed correctly however I have this issue where null or nil values cause me problems.
"userActions.cdnBusyTime" => "%{[userActions][cdnBusyTime]}"
output ends up looking like this
"userActions.cdnBusyTime" : "%{[userActions][cdnBusyTime]}",
So far I have tried several things
only change if value exists
if [userActions][cdnResources] {
mutate {add_field => {"userActions.cdnBusyTime" => "%{[userActions][cdnBusyTime]}"
}
remove value before if null
filter {
ruby {
code => "event.to_hash.delete_if {|field, value| value == '' }"
}
}
remove theh field later if it contains the name
if [userActions][cdnBusyTime] in "cdnBusyTime" {
mutate {
remove_field => ["[userActions][cdnBusyTime]"]
}
}
convert and test against !> 0
mutate {
convert => [ "[userActions][cdnBusyTime]", "integer" ]
}
if [userActions][cdnBusyTime] !> 0 {
mutate {
remove_field => [ "[userActions][cdnBusyTime]" ]
}
}
There has to be a million ways to do this. But Which one works? any suggestions?
Well, you think of it as a nested field, but when the substitution fails what is created is a top-level field. So a prune filter with the default blacklist will remove it.
So here is my issue I am putting a value in that field regardless of if its null or has a value, so the field will either have a value = 45 or "%{[userActions][cdnBusyTime]}"
I have tried to only add the field if its not null but thats not easy , as you know null does not exist in elasticsearch. So the prune would have to look for this value vs null "%{[userActions][cdnBusyTime]}"
my issue is of course the quotes and % , I dont know how to format that. Where would the actual other code go?
A prune filter can either whitelist (only retain items in the list) or blacklist (only remove items in the list). It can do this based on either the field name or the field value. I am suggesting that you blacklist based on field values (which can be a regexp).
prune { blacklist_values => [ "%\\{[^}]+\\}" ] }
That regexp is copied from the default value for the blacklist_names option. It is unclear to me why the backslashes are needed (maybe to prevent the value being sprintf'd?), so you might also want to try without them.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.