I manipulate http requests.
my event structure looks like
{
"http_body":{
"raw":"..."
}
}
I detect the content type of the requests and when it's application/json, I parse the http_body as json and endup with
{
"http_body":{
"json":{...}
}
}
I then move known information from [http_body][json] to predetermined locations
The json doesn't always contain only "known information" and I don't want to lose this unknown information but I would like to cleanup the other events
at the moment when all the information is known, i have events which endup with :
{
"http_body":{
"json":{}
}
}
and some with
{
"http_body":{}
}
when the json or http_body fields are "empty" I would like to be able to remove them but I cant figure out how to detect it without resorting to a ruby filter.
if ![http_body][json]
is false since the field is defined but is empty.
if ![http_body][json] or [http_body][json] == {}
fails with The given configuration is invalid. Reason: Expected one of #, ", ', -, [, / at line
if ![http_body][json] or ([http_body][json] == {})
fails with The given configuration is invalid. Reason: Expected one of #, ", ', -, [, / at line
the only way I found for now is
if ![http_body][json]{
mutate {
remove_field => [
"[http_body][json]"
]
}
}else{
ruby{
code =>'if(event.get("[http_body][json]").empty?) then
event.remove("[http_body][json]")
end'
}
}
which feels quite awkward .... what have I missed ?
thanks.