Splunk Search

How to create an alert if index have no data in the last 24 hours?

Neonbeeflash
Explorer

I want to create alert to check on all indexes event count and alert the list of all indexes that have no events in the last 24 hours.

I saw a post with the same problem, but it didn't help. How to create an alert if index have no data in th... - Splunk Community

The following search doesn't work for my purpose. 

| tstats count where index=* by index | where count = 0

 

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

I think you're getting no results because there's nothing for Splunk to find in empty indexes.  Try this alternative query.

| tstats count where index=* by index
```Get a list of all indexes and assign them a count of zero```
| append [|rest /services/data/indexes 
  | dedup title 
  | fields title 
  ```Discard internal indexes```
  | search title!="_*" 
  | rename title as index 
  | eval count=0
]
```Merge results, keeping the copy with a non-zero, if present```
| stats max(count) as count by index
| where count==0
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Please elaborate on "doesn't work for my purpose".

Have you looked at the blog entry referenced in linked answer?

---
If this reply helps you, Karma would be appreciated.
0 Karma

Neonbeeflash
Explorer

Thank you for your response. The problem is that I have several indexes which have not received any information in the last month. When I use this command, I get absolutely nothing. My purpose is to create a list of those indexes that have not received any information in the last 24 hours.

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

I think you're getting no results because there's nothing for Splunk to find in empty indexes.  Try this alternative query.

| tstats count where index=* by index
```Get a list of all indexes and assign them a count of zero```
| append [|rest /services/data/indexes 
  | dedup title 
  | fields title 
  ```Discard internal indexes```
  | search title!="_*" 
  | rename title as index 
  | eval count=0
]
```Merge results, keeping the copy with a non-zero, if present```
| stats max(count) as count by index
| where count==0
---
If this reply helps you, Karma would be appreciated.

Neonbeeflash
Explorer

Hello,

This worked amazing! Thanks for your help.

Get Updates on the Splunk Community!

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 ...

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...