Splunk Search

How to use where condition to set threshold for avg response time

vinayakkoli
Observer

Hi Team, I am trying to get list of apis , whose avg response time is greater than particular threshold. Using Chart and timechart to gain avg response stats in dashboard to display APIs whose avg response time is greater than particular threshold. Query using: chart command:

index=### sourcetype=### | rex field=_raw "###(?[^ ]+)" | eval fields=split(Application_Name,"-") | eval Service_name=mvindex(fields,1)."-".mvindex(fields,2) |chart span=15m avg(response_time)  over _time by Service_name where avg > 5 usenull=f | fields - OTHER

and timechart command:

index=### sourcetype=### | rex field=_raw "###(?[^ ]+)" | eval fields=split(Application_Name,"-") | eval Service_name=mvindex(fields,1)."-".mvindex(fields,2) |timechart span=15m avg(response_time) by Service_name where avg > 5 usenull=f | fields - OTHER

.Results, for both using where condition, i could still see those api ,whose avg time is less than 5sec , but near to 5sec, e.g. api with 3 sec or 3.5 comes up panel.

Labels (2)
Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this variation of the timechart search.

index=### sourcetype=### 
| rex field=_raw "###(?[^ ]+)" 
| eval fields=split(Application_Name,"-") 
| eval Service_name=mvindex(fields,1)."-".mvindex(fields,2) 
| timechart span=15m useother=f usenull=f avg(response_time) as avg by Service_name
| where avg > 5
---
If this reply helps you, Karma would be appreciated.
0 Karma

vinayakkoli
Observer

Hi @richgalloway , thank you for reply.

After trying below, with time chart now its returning zero events, but in actual events exists.


0 Karma

richgalloway
SplunkTrust
SplunkTrust

Let's debug the query.  Run this search.  Do you get results?  Is the Service_name field populated properly?

index=### sourcetype=### 
| rex field=_raw "###(?[^ ]+)" 
| eval fields=split(Application_Name,"-") 
| eval Service_name=mvindex(fields,1)."-".mvindex(fields,2) 

 

Run this search next.  Do you get results?  Is the avg field populated properly?  Is the value of the avg field greater than 5 for any row?

index=### sourcetype=### 
| rex field=_raw "###(?[^ ]+)" 
| eval fields=split(Application_Name,"-") 
| eval Service_name=mvindex(fields,1)."-".mvindex(fields,2) 
| timechart span=15m useother=f usenull=f avg(response_time) as avg by Service_name

 

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

vinayakkoli
Observer

Hi @richgalloway 

Yes, this returning the results correctly, with expected service name and avg response time greater than 5secs.

vinayakkoli_0-1592400542148.png

 



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 ...