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
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...