Alerting

Multiple conditions case statements

codedtech
Path Finder

I'm running a query to label memory thresholds for our app clusters, I would like to create a field called "eff_mem_threshold" based  off the number of blades app name.  But for the life of me I can't figure out why this case statement isn't working.  What I mean is that  it only returns the eff_mem_threshold value of the first  pair for each app and blade count. I've added an example below the case statement

Case statement

query|eval eff_mem_threshold =case(APP_NAME="EXCH_AD" and Blades<=5, 40,APP_NAME="EXCH_AD" and Blades>=17,46,APP_NAME="EXCH_AD" and Blades>=6 and Blades<=16,44,APP_NAME="VCO" and Blades<=5, 56,APP_NAME="VCO" and Blades>=17,64,APP_NAME="VCO" and Blades>=6 and Blades<=16,61,APP_NAME="SQL" and Blades<=5, 68,APP_NAME="SQL" and Blades>=17,78,APP_NAME="SQL" and Blades>=6 and Blades<=16,74)

what I see

APP_NAME

Blades

eff_mem_threshold

EXCH_AD

15

40

EXCH_AD

4

40

SQL

17

68

SQL

9

68

VCO

17

56

VCO

4

56

What I'd want to see

APP_NAME

Blades

eff_mem_threshold

EXCH_AD

15

44

EXCH_AD

4

40

SQL

17

64

SQL

9

61

VCO

78

56

VCO

4

56

 

Tags (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @codedtech,

The only reason seems to be is Blades field value is zero or less than 6. Is it possible that Blades count values are being calculated after this eval? Can you please share all SPL?

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

scelikok
SplunkTrust
SplunkTrust

Hi @codedtech,

The only reason seems to be is Blades field value is zero or less than 6. Is it possible that Blades count values are being calculated after this eval? Can you please share all SPL?

If this reply helps you an upvote and "Accept as Solution" is appreciated.

codedtech
Path Finder

That was it, sometimes staring at your own code can make you miss the simple stuff.

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...