Splunk Search

How to fill sparse data in a table for alert?

charming_fish
New Member
I have a query which results in a table:

"some words" | stats dc(host) as host_count by zone, region

My end goal is be able to create an alert if "host_count < 2" in any row. I will achieve that by adding " | where host_count < 2" to the query and alerting if the search is non-empty.

 
The issue is that in some cases, when there are no lines matching the  "some words" criteria, I will have no row for that zone/region combination in my table. (i.e. I will never have a row where host_count is 0). This will result in a false negative for the alert.

I had the thought that I could possibly merge the search result with a lookup table which provides the 0 value lines, but had no success.

How can I achieve this?
Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try the timechart command.  It will automatically fill in zeroes for missing rows.

"some words" | timechart dc(host) as host_count by zone, region
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...