Alerting

Alert for lack of conent for one host

ddrillic
Ultra Champion

We have a case in which one index gets its content from 200 hosts and we would like to get an alert when one host hasn't sent content in the past hour or so.

One way might be to run a query like this one for the past month and join it with a similar query for the past hour and determine which hosts are missing -

index=<index_name> | stats count by host | sort count asc

Does it make sense?

Tags (2)
0 Karma
1 Solution

niketn
Legend

You should either use metadata or tstats which are more specific to scenarios like this and would perform better

metadata command will give you lastTime as one of the field for timestamp of Last Event received. You can use the same to come up with your alert.

| metadata type=hosts index=<YourIndexName>
| eval lastDataDuration=(now()-lastTime)/60
| where lastDataDuration>1

Similarly for tsats

| tstats count max(_time) as lastTime WHERE index=<YourIndexName> BY host
| eval lastDataDuration=(now()-lastTime)/60
| where lastDataDuration>1
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

You should either use metadata or tstats which are more specific to scenarios like this and would perform better

metadata command will give you lastTime as one of the field for timestamp of Last Event received. You can use the same to come up with your alert.

| metadata type=hosts index=<YourIndexName>
| eval lastDataDuration=(now()-lastTime)/60
| where lastDataDuration>1

Similarly for tsats

| tstats count max(_time) as lastTime WHERE index=<YourIndexName> BY host
| eval lastDataDuration=(now()-lastTime)/60
| where lastDataDuration>1
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

ddrillic
Ultra Champion

Fascinating to see the results!!!!!

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...