Splunk Search

How to seperate status based on response time values ?

karthi2809
Builder

I need only amber and severe but i am not getting any result

base search|eval responseTime=TransactionEndtime-TransactionStartTime|eval responseTime=round((responseTime/1000),3)| stats avg(responseTime) as "avgResponseTime" by Category,Verb|eval respTimeStatus=if(avgResponseTime>15,"25",(if(avgResponseTime>=7 AND avgResponseTime<=15,"15","5"))) |rangemap field=respTimeStatus Low=0-10 Amber=11-20 Severe=21-30|stats values(range) as Status values(avgResponseTime) as avgResponseTime by Category,Verb|Where (Status="Amber" OR Status="Severe")

Tags (2)
0 Karma

DalJeanis
Legend

Try this - implemented @somesoni2's suggestions, removed the redundant second test against 15, which must always be true, removed the redundant final stats command in favor of just renaming the range field, also set final | where to lower case.

base search
    | eval responseTime=TransactionEndtime-TransactionStartTime
    | eval responseTime=round((responseTime/1000),3)
    | stats avg(responseTime) as "avgResponseTime" by Category,Verb
    | eval respTimeStatus=case(avgResponseTime>15,25, avgResponseTime>=7,15, true(),5 ) 
    | rangemap field=respTimeStatus Low=0-10 Amber=11-20 Severe=21-30
    | rename range as Status
    | where (Status="Amber" OR Status="Severe")
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The rangemap command expects numeric values, but you have text values. Try removing the quotation marks from your if statement. Also, consider using case instead of nested ifs as it's easier to read.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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