Splunk Search

Show a 0 if no data on a source

Rajaion
Path Finder

Hello community,

I'm having a problem that's probably easy to solve, but I can't figure it out.

I have a query that will query an index that contains alerts from Splunk OnCall. And I count each alert source (via the associated routingkey from OnCall) and its status (Acknowledged or not).

`victorops_incidents`  | sort lastAlertTime desc | dedup incidentNumber | fields * | search org="*" routingKey=** pagedPolicies{}.policy.name!=0_Reroute_alertes currentPhase!=RESOLVED
| eval currentPhase=case(like(currentPhase, "%UNACKED%"), "Non acquitté", like(currentPhase, "%ACKED%"), "En cours") 
| eval routingKey=case(like(routingKey, "%routingcontrol-m%"), "Control-M", like(routingKey, "%dyn%"), "Dynatrace", like(routingKey, "%centreon%"), "Centreon", like(routingKey, "%servicepilot%"), "ServicePilot", like(routingKey, "%p_1%"), "P1")
| rename currentPhase as Etat, routingKey as Source
| chart count by Etat, Source
| sort - Etat


I have an almost perfect table which summarizes everything but I am missing some information: I sometimes have a source which has not generated any alert so it is absent from the table (in the screen below, I have the sources "Control-M", "Dynatrace" and "ServicePilot" but I am missing "Centreon" because the latter did not have any incidents in the period of time) :

Rajaion_0-1701784707699.png

My question is the following: how to make all the sources appear but display 0 when they have not had any alerts?

Best regards,

Rajaion

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try like this

| table Etat, "Control-M", "Dynatrace", "ServicePilot", "Centreon"
| fillnull value=0 "Control-M", "Dynatrace", "ServicePilot", "Centreon"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| table Etat, "Control-M", "Dynatrace", "ServicePilot", "Centreon"
| fillnull value=0
0 Karma

Rajaion
Path Finder

Hi @ITWhisperer,

Thank you for your help, I have my source "Centreon" but it does not display 0 yet. I had already tried the "fillnull" but poorly because it created extra fields.

Rajaion_0-1701791257646.png

Best Regards,

Rajaion

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try like this

| table Etat, "Control-M", "Dynatrace", "ServicePilot", "Centreon"
| fillnull value=0 "Control-M", "Dynatrace", "ServicePilot", "Centreon"

Rajaion
Path Finder

I just saw your new message, it works even better and it's cleaner.
Thank you for your help !

Rajaion_0-1701792781806.png

 

0 Karma

Rajaion
Path Finder

By manually setting for a source, it works, even if it is not optimal.

| eval "Centreon"=if(isnull(Centreon),0,'Centreon')

 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...