Splunk Search

Average duration in Timechart

cclva
Explorer

Hello, new to Splunk and would appreciate some guidance. 

I want to create a timechart query to use for a dashboard to display the average response time over 24h as a trend. This is what I have so far: 

 

index= ... 
| stats min(_time) as min_t max(_time) as max_t by uniqueId
| eval duration = (max_t - min_t)* 1000
| timechart span=24h avg(duration) as AvgDur

 

This returns an empty table as a response with no average duration values. If I return just before the timechart command, I get a table with all my log responses with the correct duration. 

Could I get some guidance on why timechart isn't returning the average durations over 24h?

 

 

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

stats will reduce your pipeline of events to min_t, max_t and uniqueId - there is no _time field remaining in the events, so timechart has nothing to work with (timechart expects _time to be present in the events). You should probably select one of the times to be used for _time

index= ... 
| stats min(_time) as min_t max(_time) as _time by uniqueId
| eval duration = (_time - min_t)* 1000
| timechart span=24h avg(duration) as AvgDur

 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

stats will reduce your pipeline of events to min_t, max_t and uniqueId - there is no _time field remaining in the events, so timechart has nothing to work with (timechart expects _time to be present in the events). You should probably select one of the times to be used for _time

index= ... 
| stats min(_time) as min_t max(_time) as _time by uniqueId
| eval duration = (_time - min_t)* 1000
| timechart span=24h avg(duration) as AvgDur

 

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