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

Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...