Splunk Search

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

Neel881
Path Finder

Hello,

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

Query:

| tstats count as Total where index="abc"  by _time, Type span=1d

Getting:

Neel881_0-1695132638207.png

Required:

Neel881_1-1695132682156.png

 

Please suggest

 

Thank You

 

0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| tstats count as Total where index="abc"  by _time, Type span=1d
| timechart span=1d max(Total) as Total by Type
| untable _time Type Total

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Try this.  The timechart command should fill in empty time slots automatically.

| tstats prestats=true count as Total where index="abc"  by _time, Type span=1d
| timechart span=1d cont=true count as Total by Type

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

Neel881
Path Finder

Same output

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try with fillnull

| tstats count as Total where index="abc"  by _time, Type span=1d
| timechart span=1d max(Total) as Total by Type
| fillnull value=0
| untable _time Type Total

Neel881
Path Finder

Fillnull works properly in my case. Thank you!

 

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| tstats count as Total where index="abc"  by _time, Type span=1d
| timechart span=1d max(Total) as Total by Type
| untable _time Type Total

Neel881
Path Finder

Thank you, Now I am getting correct output but Phase data is missing.

| tstats count as Total where index="abc"  by _time, Type, Phase span=1d
| timechart span=1d max(Total) as Total by Type
| untable _time Type Total

 Phase field is missing in the final table.

I tried to add 'Phase' field in the untable but showing error.

 

Pls suggest

0 Karma

Neel881
Path Finder

Got the solution. Thank you so much.

0 Karma
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...