Splunk Search

Index Health and Welfare Tstats count

RobK700000
New Member

I am trying to run a daily report that tells me all the indexes that have had 0 events in the past 24 hours. From other searches I have found the below query which seems to work fine except I want to not include certain indexes that I know will always be a 0 count. So for example if I know indexes named index1, index2 and index3 will always be 0 and want them not to show up in the report how would one accomplish that?

This is the base search without removing any indexes from results. Appreciate any advice thanks.

| tstats count where index=* by index
| 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

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @RobK700000 ,

if they are many, you could use a lookup containing the indexes exception list,

| tstats count where index=* by index
| append [
     |rest /services/data/indexes
     | dedup title
     | fields title
     ```Discard internal indexes```
     | search title!="_*" OR NOT [ | inputlookup indexes_exception_list.csv | fields 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

otherwise (if they are few), you could add them to the subsearch:

| tstats count where index=* by index
| append [
     |rest /services/data/indexes
     | dedup title
     | fields title
     ```Discard internal indexes```
     | search title!="_*" OR NOT index IN (index1, index2, index3)
     | 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

 Ciao.

Giuseppe

0 Karma

PickleRick
SplunkTrust
SplunkTrust

s/OR NOT/AND NOT/g

You want to exclude any of those indexes. If you use OR NOT and have more than one index in your list, it will always match the OR NOT condition.

0 Karma

PickleRick
SplunkTrust
SplunkTrust

You define a lookup (let's call it badindexes.csv) with a single column containing index names to filter out (let's call this column "index")

You can use this lookup to find if you want an index to be filtered out

| lookup badindexes.csv index outputnew index as match

Now you can just leave all results which do not have this field populated

| search match!=*

or

| where isnull(match)
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...