Hi, I am looking for a solution to a problem that has been addressed here:
Using a column of field names to dynamically select fields for use in eval expression
but with this difference:
Original solution was:
| makeresults
| eval raw="x1 y1 z1 field1 x1::x2 y2 z2 field3 z2::x3 y3 z3 field2 y3"
| makemv delim="::" raw
| mvexpand raw
| rex field=raw "(?<field1>\S+)\s+(?<field2>\S+)\s+(?<field3>\S+)\s+(?<lookup>\S+)\s+(?<expected_result>\S+)"
| fields - raw _time
| rename COMMENT AS "Everything above fakes sample data; everything below is your solution."
| eval result="N/A"
| foreach field* [eval result=if(lookup="<<FIELD>>", $<<FIELD>>$, result)]
In the | foreach... command is used field* as an set of input fields. But in my case the set of input fields cannot be described by wildcard, there is lot of field names in my input "list".
I have decided to create multivalue field with all values in lookup column:
| eventstats values(lookup) as mv_lookup
That created mv field mv_lookup I want to use as input for | foreach... command.
| foreach mode=multivalue mv_lookup [eval result=if(lookup="<<FIELD>>", $<<FIELD>>$, result)]
I guess, if foreach command input is MV field, i have to use <<ITEM>> instead of <<FIELD>> and that is the reason for no match in lookup="<<FIELD>>" Does exist any way how to use MV list of values (names of fields) to perform requested lookup?
Thanks in advance.
David
... View more