Splunk Search

How to fill the gaps from days with no data in tstats + timechart query?

mciudad
Explorer

Hello,

I'm trying to get the statistics of the bytes transferred each day with a query like this:

 | tstats prestats=t  sum(bytes) from datamodel=DM earliest=-7d@d latest=@d by _time span=1d | timechart span=1d sum(bytes) as "Bytes"

And the results are something like this, skipping the days with no data:

_time        Bytes
2015-06-16  5509565371
2015-06-17  15556005605
2015-06-18  15556685676
2015-06-19  9722873606 

What I need is to fill the days with no data with 0s, something like this:

_time        Bytes
2015-06-15  0
2015-06-16  5509565371
2015-06-17  15556005605
2015-06-18  15556685676
2015-06-19  9722873606
2015-06-20  0
2015-06-21  0 

How could I make that possible without lowering the performance?

Tags (4)
0 Karma
1 Solution

woodcock
Esteemed Legend

It should already be doing that (that is what it does) but just in case try adding cont=t. In either case, DEFINITELY open a support ticket to report this bug.

http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Timechart

View solution in original post

jiaqya
Builder

I see it was answered to be done using timechart, but how to do the same with tstats.
tstats does not show a record for dates with missing data...

the fillnull_value option also does not work on 726 version.

0 Karma

woodcock
Esteemed Legend

It should already be doing that (that is what it does) but just in case try adding cont=t. In either case, DEFINITELY open a support ticket to report this bug.

http://docs.splunk.com/Documentation/Splunk/6.2.3/SearchReference/Timechart

mciudad
Explorer

Thank you, you were right!

What if there is no data in any day? In that case it returns "No results found. " but it should return just 0 bytes per day.

0 Karma

woodcock
Esteemed Legend

According to the dox and every usage I have ever tried, timechart will fill in any empty span slots with 0-values, as long as cont=t (which is the default).

0 Karma
Get Updates on the Splunk Community!

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...

Stay Connected: Your Guide to July and August Tech Talks, Office Hours, and Webinars!

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...

Edge Processor Scaling, Energy & Manufacturing Use Cases, and More New Articles on ...

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