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!

Splunk Enterprise Security 8.0.2 Availability: On cloud and On-premise!

A few months ago, we released Splunk Enterprise Security 8.0 for our cloud customers. Today, we are excited to ...

Logs to Metrics

Logs and Metrics Logs are generally unstructured text or structured events emitted by applications and written ...

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...