Splunk Search

Giving multiple events a field based on one events value

TooManyQuestion
Explorer

Hello!

What I'm trying to do is if check if any of the events meet a criteria and if so I want to assign all events a particular field and value.

E.G.
I want to check if any of the RequiredValue field has a value of "Yes". If so all events get the ConditionalValue of "Yes" if not they all get a value of "No"

IDRequiredValueConditionalValue
1NoYes
2NoYes
3NoYes
4YesYes
5No

Yes

 

 

Any help would be greatly appreciated. Thanks!

 

 

Labels (4)
0 Karma
1 Solution

to4kawa
Ultra Champion
| makeresults count=5 
| streamstats count as ID 
| eval RequiredValue=mvindex(split("Yes,No",","),random() % 2) 
| rename COMMENT as "This is sample. Each time you search, the value changes.
From here, the logic." 
| eventstats count(eval(RequiredValue="Yes")) as ConditionalValue 
| eval ConditionalValue=if(ConditionalValue > 0,"Yes","No") 
| table ID RequiredValue ConditionalValue

View solution in original post

to4kawa
Ultra Champion
| makeresults count=5 
| streamstats count as ID 
| eval RequiredValue=mvindex(split("Yes,No",","),random() % 2) 
| rename COMMENT as "This is sample. Each time you search, the value changes.
From here, the logic." 
| eventstats count(eval(RequiredValue="Yes")) as ConditionalValue 
| eval ConditionalValue=if(ConditionalValue > 0,"Yes","No") 
| table ID RequiredValue ConditionalValue

TooManyQuestion
Explorer

Thanks so much! Worked like a charm!

0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...