Dashboards & Visualizations

timechart only show lines that have spikes

mauricio2354
Explorer

I have a query:

index=source STATUS=499 SERVICE!="Health#*"| timechart useother=f span=1m count by SERVICE

That will have large spikes sometimes. I want to only show the services that have those large spikes. How do I do that?
If there's no way to have spikes be detailed as greater than twice the average count or something, greater than 20 would be fine.

Thanks so much!

Tags (1)
0 Karma
1 Solution

elliotproebstel
Champion

How about this, which finds all services that have timespans with a count greater than the average plus the standard deviation for that service OR a count less than the average minus the standard deviation for that service.

index=source STATUS=499 SERVICE!="Health#*"
| bin _time span=1m
| stats count BY SERVICE _time
| eventstats avg(count) as avg_count stdev(count) AS std_dev_count max(count) AS max_count min(count) AS min_count BY SERVICE 
| where max_count>avg_count+std_dev_count OR min_count<avg_count-std_dev_count 
| timechart useother=f values(count) AS count by SERVICE

View solution in original post

0 Karma

elliotproebstel
Champion

How about this, which finds all services that have timespans with a count greater than the average plus the standard deviation for that service OR a count less than the average minus the standard deviation for that service.

index=source STATUS=499 SERVICE!="Health#*"
| bin _time span=1m
| stats count BY SERVICE _time
| eventstats avg(count) as avg_count stdev(count) AS std_dev_count max(count) AS max_count min(count) AS min_count BY SERVICE 
| where max_count>avg_count+std_dev_count OR min_count<avg_count-std_dev_count 
| timechart useother=f values(count) AS count by SERVICE
0 Karma

mauricio2354
Explorer

I like this idea! I don't think the eventstats works too well for my query, so going with "had a spike of greater than 20" would be like this, right?

index=source STATUS=499 SERVICE!="Health#*"
| bin _time span=1m
| stats count BY SERVICE _time
| where count> 20
| timechart useother=f values(count) AS count by SERVICE

The only problem here is that when I visualize it, it only shows the points where those services hit above 20, and not the whole line. Would you know how to include the whole line?

0 Karma

elliotproebstel
Champion

BTW, I apologize but I had a typo in the eventstats line on my original post - it was a copy/paste error moving from my test environment to yours. I fixed it now, so you might give it another try.

0 Karma

mauricio2354
Explorer

Hmm the original post is still giving me some trouble with showing the full line, but the last query you showed me works perfectly! Thanks so much for all the help!

0 Karma

elliotproebstel
Champion

Glad we got it sorted!

0 Karma

elliotproebstel
Champion

That's the point of using eventstats. It allows you to retain all the original data while finding the min and max values. If the originally proposed approach doesn't work, here's a less calculation-intensive example of eventstats:

index=source STATUS=499 SERVICE!="Health#*"
| bin _time span=1m
| stats count BY SERVICE _time
| eventstats max(count) AS max_count BY SERVICE 
| where max_count>20
| timechart useother=f values(count) AS count by SERVICE
0 Karma

elliotproebstel
Champion

If that still doesn't work, you could try this:

index=source STATUS=499 
 [ search index=source STATUS=499 SERVICE!="Health#*"
 | bin _time span=1m
 | stats count BY SERVICE _time
 | where count> 20
 | fields SERVICE ]
| timechart useother=f span=1m count by SERVICE

This will use a subsearch to isolate the services that had spikes and then search for all events from those services and create a timechart.

0 Karma

JDukeSplunk
Builder

Maybe?

  index=source STATUS=499 SERVICE!="Health#*"
|where SERVICE =>20
| timechart useother=f span=1m count by SERVICE
0 Karma

mauricio2354
Explorer

Unfortunately, that doesn't work. I think you were looking for ">=" instead of "=>" and each SERVICE is a string, not an integer. This still wouldn't work if you counted by "count" either

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!

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

Index This | How many sevens are there between 1 and 100?

August 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...