Is there any way to tell the difference between an empty variable and a non-existent one? The code
if [v1] == "" {
do something
}
acts exactly the same whether the variable exists and is empty or does not exist at all. The trouble is that the following code has two different results depending on whether the variable exists or not:
if [v1] == "" {
mutate { add_field => { "[v2]" => "value2" } }
}
If [v1] does not exist then [v2] contains "value2". If [v1] exists and is empty then [v2] is an array ["", "value2"]. If I change the add_field to update then in the first case [v2] does not get created (cannot update a non-existent variable) and [v2] is a scalar "value2".