Splunk Search

Query on stats value = 0 or null

christay
New Member

Hi Guys,

I have a question here.
Example i have a query statement that check for event logs captured by all my servers(Say total i have 30) during the last 10 mins.

if i run the following query :
index=ind_audit_log (sourcetype=linux_secure OR sourcetype=linux_audit) | stats count by host

It only returns me 25 servers which has event logs being pipe to splunk. The rest of the servers(5 in total) that does not have event logs pipe to splunk was not being reflected in the above query.

How can i craft and run a query to sieve out those servers that does not have any event logs being pipe to my splunk so that i can create an alert to notify me to check on the servers.

Thanks!

0 Karma
1 Solution

HiroshiSatoh
Champion

I think that using LOOKUP FILE is a staple, but there are also such search sentences.

|tstats count  
      WHERE index=ind_audit_log AND (sourcetype=linux_secure OR sourcetype=linux_audit) 
      by host 
| append [| metadata type=hosts index=ind_audit_log |eval count=0|table host,count]
| stats sum(count) as count by host

Unnecessary hosts should be excluded by WHERE clause etc.

View solution in original post

0 Karma

HiroshiSatoh
Champion

I think that using LOOKUP FILE is a staple, but there are also such search sentences.

|tstats count  
      WHERE index=ind_audit_log AND (sourcetype=linux_secure OR sourcetype=linux_audit) 
      by host 
| append [| metadata type=hosts index=ind_audit_log |eval count=0|table host,count]
| stats sum(count) as count by host

Unnecessary hosts should be excluded by WHERE clause etc.

0 Karma

christay
New Member

Hi Hiroshi,

Thanks for the query, it works as intended.

Cheers.

0 Karma
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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

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