Splunk Search

How to do Conditional Searches?

secphilomath
New Member

Is there a way to do a search like this;

If Eventid=1111

    only do these  statements

elseif Eventid=2222

    only do these statements

elseif eventid=3333

   only do these statements

Do these extra statements ...

Labels (1)
Tags (1)
0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@secphilomath - Not sure what is your goal exactly but based on what you have described, you can try appendpipe command.

<your-search>
| appendpipe [| search event_id=1 | mycommand1 ]
| appendpipe [| search event_id=2 | mycommand2 ]
<anything else>

 

I hope this helps!!!

0 Karma

bowesmana
SplunkTrust
SplunkTrust

You can do if logic in eval statements, but there is no "if" block. It will depend on what you want to do in those conditions.

You can often achieve if type logic, can you give an example of the sort of actions you want to take.

 

0 Karma

secphilomath
New Member

Essentially I want to run 3 different search commands depending on the value of the eventid.  

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...