Splunk Search

stats count not working

dbashyam
Explorer

Hi, I am trying to get a table type of alerting but I am not getting the output

 index = ops host = Sr*xxxx* sourcetype=iislogs (HttpStatusCode =400 OR  HttpStatusCode = 401 OR HttpStatusCode = 403 OR HttpStatusCode = 404 OR HttpStatusCode = 405) AND (*loadbalancer* OR *gateway* OR *IFT* OR *widget* ) NOT ( *.png OR *.gif OR *.css OR *fonts* OR *.txt OR *.gif OR *.ico OR *.jpg OR *.pdf OR *.exe OR *.cgi OR *.swf OR *.vmd OR *.xsl OR *.xml OR *qualy* OR *woff* OR *.bak OR *.png OR *.svg OR *.ttf OR *.ini OR *.temp OR *.data OR *.tar OR *curl* OR *.po OR *.mo OR *.tpl OR *.tmpl OR *script*) | bin _time span=5m |stats count as avg_count by _time | where avg_count > 4 | eval alert="'splunk:".host.";crit;welcome to splunk  Error ".host.";Process;rr_os;mmtt;tt_3'" | table alert

I am expecting a table form but I don't get anything. Could you please help.

Thanks,
Dinesh

Tags (2)
0 Karma
1 Solution

nickhills
Ultra Champion

after you run stats count as avg_count by _time there is no longer a field called 'host'

You can resolve this by using by _time, host instead.

index=ops host=Sr*xxxx* sourcetype=iislogs (HttpStatusCode=400 OR HttpStatusCode=401 OR HttpStatusCode=403 OR HttpStatusCode=404 OR HttpStatusCode=405) AND (*loadbalancer* OR *gateway* OR *IFT* OR *widget* ) NOT ( *.png OR *.gif OR *.css OR *fonts* OR *.txt OR *.gif OR *.ico OR *.jpg OR *.pdf OR *.exe OR *.cgi OR *.swf OR *.vmd OR *.xsl OR *.xml OR *qualy* OR *woff* OR *.bak OR *.png OR *.svg OR *.ttf OR *.ini OR *.temp OR *.data OR *.tar OR *curl* OR *.po OR *.mo OR *.tpl OR *.tmpl OR *script*) 
| bin _time span=5m 
| stats count as avg_count by _time, host
| where avg_count > 4 
| eval alert="'splunk:".host.";crit;welcome to splunk  Error ".host.";Process;rr_os;mmtt;tt_3'" 
| table alert
If my comment helps, please give it a thumbs up!

View solution in original post

0 Karma

nickhills
Ultra Champion

after you run stats count as avg_count by _time there is no longer a field called 'host'

You can resolve this by using by _time, host instead.

index=ops host=Sr*xxxx* sourcetype=iislogs (HttpStatusCode=400 OR HttpStatusCode=401 OR HttpStatusCode=403 OR HttpStatusCode=404 OR HttpStatusCode=405) AND (*loadbalancer* OR *gateway* OR *IFT* OR *widget* ) NOT ( *.png OR *.gif OR *.css OR *fonts* OR *.txt OR *.gif OR *.ico OR *.jpg OR *.pdf OR *.exe OR *.cgi OR *.swf OR *.vmd OR *.xsl OR *.xml OR *qualy* OR *woff* OR *.bak OR *.png OR *.svg OR *.ttf OR *.ini OR *.temp OR *.data OR *.tar OR *curl* OR *.po OR *.mo OR *.tpl OR *.tmpl OR *script*) 
| bin _time span=5m 
| stats count as avg_count by _time, host
| where avg_count > 4 
| eval alert="'splunk:".host.";crit;welcome to splunk  Error ".host.";Process;rr_os;mmtt;tt_3'" 
| table alert
If my comment helps, please give it a thumbs up!
0 Karma

dbashyam
Explorer

yes that worked @nickhillscpl

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...