Splunk Search

Splunk query to aggregate hourly event count per hosts

swinod
New Member

How can i get the hourly count of events per host (events in the past 24 hours). For e.g.
|metadata type=hosts index=* , gives the totalcount. Is there a way to aggregate this number by events in an hour. I would like to have one row for every host and the column header to be more like -
host, totalcount, Hour(1), Hour(2), Hour (3), Hour (4).....Hour (24), where the aggregate of Hour(1) to Hour (24) adds to the totalcount.

Tags (1)
0 Karma

renjith_nair
Legend

@swinod ,

Try this and test

|tstats count where index=*  by _time,host span=1h |eval time=strftime(_time,"%H")
|chart first(count) over host by time| addtotals fieldname=Total row=t

You may adjust the index part to get the count from specific index

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
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!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...