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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...