Logstash version 6.3.0
I'm using the kv filter with the default settings, which means:
value_split => "="
field_split => " "
If I send a message with the format of key=
without a value on the other side, it interprets the following key-value as the value for that key. Meaning, key= key2=value
is interpreted the same as key="key2=value"
. You can replicate this behavior by running Logstash with
bin/logstash -e "input{ stdin{} } filter{ kv{} } output{ stdout{} }"
and then try the following inputs through stdin:
All keys w/ values (pass)
input: key1=value1 key2=value2 key3=value3
output:
{
"@version" => "1",
"key1" => "value1",
"message" => "key1=value1 key2=value2 key3=value3\r"
"host" => "logstash",
"@timestamp" => 2018-08-03T19:16:11.129Z,
"key2" => "value2",
"key3" => "value3\r"
}
second key missing value (fail)
input: key1=value1 key2= key3=value3
output:
{
"@version" => "1",
"key1" => "value1",
"message" => "key1=value1 key2= key3=value3\r",
"host" => "logstash",
"@timestamp" => 2018-08-03T19:16:20.520Z,
"key2" => "key3=value3\r"
}
first key missing value (fail)
input: key1= key2=value2 key3=value3
output:
{
"@version" => "1",
"key1" => "key2=value2",
"message" => "key1= key2=value2 key3=value3\r",
"host" => "logstash",
"@timestamp" => 2018-08-03T19:16:34.751Z,
"key3" => "value3\r"
}
first key with empty quote (pass)
input: key1="" key2=value2 key3=value3
output:
{
"@version" => "1",
"message" => "key1=\"\" key2=value2 key3=value3\r",
"host" => "logstash",
"@timestamp" => 2018-08-03T19:16:49.252Z,
"key2" => "value2",
"key3" => "value3\r"
}
last key with missing value (pass)
input: key1=value1 key2=value2 key3=
output:
{
"@version" => "1",
"key1" => "value1",
"message" => "key1=value1 key2=value2 key3=\r",
"host" => "logstash",
"@timestamp" => 2018-08-03T19:17:34.828Z,
"key2" => "value2"
}
Is there a way to tell the kv filter that an empty space after the =
means the key has a null value?
Thanks