Splunk Search

If/Then To different Eval Statements

albyva
Communicator

I'm trying to have a Splunk Alert kick off an email (to an email script) and depending on the search query it should email Address1 or Address2. How do you I create this type of variable? Should I setup a where statement like | where search=Apples | eval email="address1" |where search=Oranges | eval email="address2" ????

Example:

[search yields Apples] | eval email="address1"

[search yields Oranges] | eval email="address2"

0 Karma
1 Solution

pradeepkumarg
Influencer

You can club if and eval as below.

eval email=if(mycondition,"address1","address2")

View solution in original post

somesoni2
Revered Legend

Try this

| eval email=if(like(BPS,"%Gbps"),"address1","address2") 

albyva
Communicator

Thank You !!!! 🙂

0 Karma

pradeepkumarg
Influencer

You can club if and eval as below.

eval email=if(mycondition,"address1","address2")

albyva
Communicator

Can you add a wildcard into mycondition?

I see where if(X,Y,Z) says: This function takes three arguments. The first argument X is a Boolean expression. If X evaluates to TRUE, the result is the second argument Y. Optionally, if X evaluates to FALSE, the result evaluates to the third argument Z.

My problem now is that (X) is something like 123.45 Gbps or 45.67 Mbps. My goal is to have Gbps send email to address1 and everything go to address2.

Example:

| eval email=if(BPS="Gbps","address1","address2")

The problem appears to be that if I say Gbps or even *Gbps in the X field, neither seem to work. It's only when I specify the exact value like 123.45 Gbps does it actually work. So what I need is a wildcard, but that isn't working. Any suggestions???

Thanks

0 Karma

pradeepkumarg
Influencer

Yes, you should be able to do it.. You can also try to extract just Gbps and Mbps into a field before the condition and try the comparison on that field.

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...