wwalker
(Walker)
March 14, 2018, 3:08pm
1
I have multiple fields that I need to check and, if they meet a shared value, it needs to be mutated. Is it possible to do something like this:
if "pass" in [field1] or [field2] or [field3] {
mutate {
replace "%{FieldThatMeetsEvaluation}" => "Pass"
}
}
So I guess two questions here:
Can I use a single if statement to check multiple fields for a value being present?
Is it possible to reference the field(s) that match later on run a filter on the field?
Can I use a single if statement to check multiple fields for a value being present?
if "pass" in [field1] or "pass" in [field2] or "pass" in [field3] {
Is it possible to reference the field(s) that match later on run a filter on the field?
No.
wwalker
(Walker)
March 15, 2018, 8:30pm
4
So I would have to write something like?
filter {
if "pass" in [field1] {
mutate {
replace => {"field1" => "Pass"}
}
}
if "pass" in [field2] {
mutate {
replace => {"field2" => "Pass"}
}
}
if "pass" in [field3] {
mutate {
replace => {"field3" => "Pass"}
}
}
}
Badger
March 15, 2018, 8:37pm
5
It might be possible to use add_field to build a string containing the three fields as key=value pairs, then use grok to do a match for SOMEPATTERN=Pass, then a replace based on the value captured by grok.
But it will make your eyes bleed.
wwalker
(Walker)
March 15, 2018, 8:41pm
6
Badger:
It might be possible to use add_field to build a string containing the three fields as key=value pairs, then use grok to do a match for SOMEPATTERN=Pass, then a replace based on the value captured by grok.
But it will make your eyes bleed.
lol, just your explanation melts my brain. I think the deciding factor would be, which method can be processed faster.
Badger
March 15, 2018, 9:28pm
7
Thankfully it does not work. I can get a field name into a field called whichone, but I cannot get the left side of a mutate/replace to reference it.
BTW '"pass" in [field1]' is almost certainly not what you want. Are you looking for '"[field1] =~ "pass"', perhaps?
wwalker
(Walker)
March 15, 2018, 9:43pm
8
My field(s) SHOULD have one of two values, pass
or fail
. Unfortunately, some of the data that gets ingested also has Pass
. This throws off visualizations, where for example, pie graphs have three slices instead of two.
Badger
March 15, 2018, 10:19pm
9
So mutate/lowercase would fix your issue?
wwalker
(Walker)
March 16, 2018, 11:45pm
10
Yes.....yes it would.....lol. Thanks.
system
(system)
Closed
April 13, 2018, 11:45pm
11
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.