Splunk Search

How to use timechart to display whether a log exists or not over a certain time range in 15 minute buckets?

JohnCM8181
New Member

I am trying to write a search that displays a table that shows whether a log in cloud watch exists or not every 15 minutes over a 5 hour period. The caveat being that I would like it to show a 0 for time intervals that don’t have the log even if they’re in the future. I’m also having trouble formatting the result table so that the time intervals are the columns/x axis and the count is row/y-axis.

Any help would be greatly appreciated, thanks!

Labels (5)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Assuming that you are using line chart, and you want the value to be 1 when log exists and 0 when there is no log during the bucket, something like this will do

| tstats count where source=cloud_log earliest=-3h latest=+2h by _time span=15m
| timechart sum(eval(if(count > 0, 1, 0))) as has_log
| fillnull value=0

If you only want to display line on the zero axis and don't care how the column look like, you can skip fillnull, just set visualization to touch zero.

 

0 Karma
Get Updates on the Splunk Community!

What’s New & Next in Splunk SOAR

Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us on ...

Your Voice Matters! Help Us Shape the New Splunk Lantern Experience

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

September Community Champions: A Shoutout to Our Contributors!

As we close the books on another fantastic month, we want to take a moment to celebrate the people who are the ...