Splunk Dev

Splunk query to Check when no value is returned

masmi99
Explorer

Scenario:

Example query :  index=XXXX name=somefile | stats count(msg) as MESSAGE

The above query will always return some count.

I want to alert if the Message=0 for two consecutive 5 min interval over the last 15 min interval i.e. when no values are returned.

earliest=-15m if two out of three interval (5min) the message=0 i want to take some actions

Labels (1)
0 Karma

codebuilder
Influencer

Just add this to the end of your alert query:

| where result_count=0

----
An upvote would be appreciated and Accept Solution if it helps!
0 Karma

masmi99
Explorer

when i add where MESSAGE=0 it is not returning any result

As my intention is to check for last 15 min if two of 5 min interval does not get any result to do some other action

index=XXX name=file-XXX level<50
| bucket _time span=5m
| fillnull value=0
| stats count(msg) as MESSAGES by _time

tried this but this will provide the result as follows it skipped 3:25 when  the count was 0

2021-08-18 03:20:0025
2021-08-18 03:30:00139
2021-08-18 03:35:0010
  
Tags (1)
0 Karma

codebuilder
Influencer

The problem with you query is that you are not eliminating events where "msg" has a non null value. That's why youre getting results with counts.

Try something like this:

index=XXX name=file-XXX | fields + msg level<50
| bucket _time span=5m
| fillnull value=0
| where msg=0
| stats count(msg) as MESSAGES by _time
----
An upvote would be appreciated and Accept Solution if it helps!
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!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...