Splunk Search

Timechart with moving count

jrs42
Path Finder

I'm trying to (efficiently) create a chart that collects a count of events, showing the count as a value spanning the previous 24h, over time.  i.e. every bin shows the count for the previous 24h.

This is intended to show the evaluations an alert is making every x minutes where it triggers if the count is greater than some threshold value.  I'm adding that threshold to the chart as a static line so we should be able to see the points at which the alert could have triggered.

I have the following right now, but it's only showing one data point per day when I would prefer the normal 100 bins

 

...
| timechart span=1d count
| eval threshold=1000

 

Hope that's not too poorly worded 🙂

Labels (1)
0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

I'm not sure if I understood your question correctly, but maybe you could get this done with streamstats?

You could use it first to calculate that sliding count for previous 24h and then use timechart with values/max to show those into your chart.

See https://docs.splunk.com/Documentation/Splunk/9.2.0/SearchReference/Streamstats use it with  time_window=1d

...
| streamstats time_window=1d count as dailyCount ....
| timechart max(dailyCount) as dailyCount max(threshold) as threshold ...

Use span on timechart and any other aggregate values which you maybe need.

r. Ismo 

0 Karma

jrs42
Path Finder

Unfortunately, that's not it.  Let me try to clarify 🙂

Right now, I get results with one value per day so if I pick "last 7 days" I only see 7 data points which is much too coarse.  I'd prefer to have the normal "100 bins" or points of data, with each one the count of events for the preceding 24h from when that data point/bin is in time.  The end result would be a much smoother chart, basically showing the count value my alert is checking. 

It's looking to me that as soon as I pick "last 7 days", I'm in the realm of days and I cannot plot with more granularity.

0 Karma

PickleRick
SplunkTrust
SplunkTrust

That's what @isoutamo is talking about. This is what streamstats does. With properly set window (either in terms of number of events or time) it can calculate stats over moving window.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Build the Future of Agentic AI: Join the Splunk Agentic Ops Hackathon

AI is changing how teams investigate incidents, detect threats, automate workflows, and build intelligent ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...