Hello,
I would like to know if it would be possible to set default value for a field in Logstash if the field is null or if it doesn't exist.
In my example, I have a "dead_letter_queue" input where I can have one, two or three fields :
A | B | C
A | B
A | C
...
Now, I want to write a "dead_letter_queue" file where I will write (for the example above) :
A|B|C
A|B|
A||C
To do that, I created this config file :
input {
dead_letter_queue {
path => "/usr/share/logstash/data/dead_letter_queue"
pipeline_id => "main"
commit_offsets => true
}
}
output {
file {
path => "/path_to_my_file/dead_letter_queue.log"
codec => line {
format => "%{A}|%{B}|%{C}"
}
}
}
However, the output file looks like this :
A|B|C
A|B|%{C}
A|%{B}|C
I could check each field in a filter and if the field doesn't exist I could create it with the value "", but it will not be very optimal if I have 20 fields or more (I will have 20 "if" condifitions).
My question is : Is it possible to set a default value in Logstash if the field doesn't exist or if its value is null? Something like this?
format => "%{A:default_value}|%{B:default_value}|%{C:default_value}"
Thank you in advance for your help.