Splunk Search

Add a value "0" and make it visible on a graph

Rajaion
Path Finder

Hello community,

I'm encountering a problem that's probably simple to correct, but no matter how hard I try, I can't do it. I have a query that returns several results that I count according to the time range.

Rajaion_0-1698656156390.png


This allows me to provide a graph showing the hourly load. However, I noticed that when there was no result over a time range (for example between 3:00 a.m. and 4:00 a.m.), the graph does not appear in full, I am missing the time range in question :

Rajaion_1-1698656188397.png

Here is my current query:

index="oncall_hp" currentPhase=UNACKED routingKey=*event* entityDisplayName!=*Local-Self-Monitoring*
| dedup incidentNumber
| eval Heure = strftime(_time, "%H")
| stats count by Heure
| rename count AS Events
| sort Heure


I tried to force the appearance of a "0" value if there was nothing but that didn't change:

index="oncall_hp" currentPhase=UNACKED routingKey=*event* entityDisplayName!=*Local-Self-Monitoring*
| dedup incidentNumber
| eval Heure = strftime(_time, "%H")
| stats count by Heure
| rename count AS Events
| eval Events=if(isnull(Events) OR len(Events)==0, "0", Events) 
| sort Heure

 

I looked on the forum to see if other people had had this problem but I couldn't find it (or I didn't look well).

Do you have an idea to simply add a "0" value if a time slot is empty, and that adds it to the graph?

Best regards,

Rajaion

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
index="oncall_hp" currentPhase=UNACKED routingKey=*event* entityDisplayName!=*Local-Self-Monitoring*
| dedup incidentNumber
| timechart count span=1h
| fillnull value=0 count
| eval Heure = strftime(_time, "%H")
| stats sum(count) as Events by Heure

View solution in original post

Rajaion
Path Finder

Hello @ITWhisperer,

Thank you for your help. Indeed, it displays empty columns. However, I notice the time is added to the graph but for each day present in the graph:

Rajaion_0-1698658613476.png

I can delete the display for each day but it only works well on one day:

Rajaion_1-1698658695036.png

Because over several days, we group by time slot but it does not add the values ​​of the same time slot. I tried adding everything up but it doesn't respond at all after that.

Do you know how to just add everything up for each time slot?

Best regards,

Rajaion

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
index="oncall_hp" currentPhase=UNACKED routingKey=*event* entityDisplayName!=*Local-Self-Monitoring*
| dedup incidentNumber
| timechart count span=1h
| fillnull value=0 count
| eval Heure = strftime(_time, "%H")
| stats sum(count) as Events by Heure

Rajaion
Path Finder

Oh yes, I had forgotten the use of sum, in fact, it works perfectly.

Rajaion_0-1698670189623.png

 

Thank you very much for your help.

Best regards,

Rajaion

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The issue is not the chart, it is with your stats table. Because no data exists for those hours, there are no rows (and therefore no corresponding column). Using timechart instead of stats will fill in the missing time slots, you then just need to convert the null counts to zeroes. Try something like this

index="oncall_hp" currentPhase=UNACKED routingKey=*event* entityDisplayName!=*Local-Self-Monitoring*
| dedup incidentNumber
| timechart count span=1h
| fillnull value=0 count
| eval Heure = strftime(_time, "%H")
| rename count AS Events
| sort 0 Heure

 

Get Updates on the Splunk Community!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...