Handle null values from inuput


(Varun) #1

I am using http as my source and as a first operation in filter, renaming the incoming columns as shown below for a column

mutate{
add_field => {"AccID" => "%{variable}"}
}
when i insert this into target,

i see column value to be inserted as "%{variable}" itself for rows with no value for AccID.

also in certain cases, response doesnt return certain columns based on the http URL defined and we get an error pointing to invalid number as it inserts the above variable into number column in database .

how can this be handled as we need to make sure to insert this as null in case the above scenarios occur


(Tamara Rosini) #2

Hi,

You should add an if clause like this:

  if [dimensions][0] {
    mutate { 
     add_field => {"AccID" => "%{rowid[dimensions][0]}"}
    }
  }

I am assuming that rowid is not a variable but a static field otherwise it should be between [] as well.