jrihds
May 23, 2019, 8:24am
#1
Hello,
Is it possible to add a new field whose name is based on data from the message? e.g.
add_field => {
"%{[parsed-json][0][key]}" => "%{[parsed-json][0][value]}"
}
I am currently getting an 'Invalid FieldReference' error.
For completeness, the following config works successfully but doesn't achieve what I need:
add_field => {
"value-field" => "%{[parsed-json][0][value]}"
"key-field" => "%{[parsed-json][0][key]}"
}
Thank you
jrihds
May 23, 2019, 9:19am
#2
I worked out a solution. I needed to add validation to ensure that the data exists before I try and create a field for it, as below:
if [parsed-json][0] {
mutate {
add_field => {
"%{[parsed-json][0][key]}" => "%{[parsed-json][0][value]}"
}
}
}
system
(system)
closed
June 20, 2019, 9:19am
#3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.