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
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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