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.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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