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!

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...

Index This | When is October more than just the tenth month?

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