Splunk Search

Getting the time that maximum count occurs every hour

klodian90
New Member

I have a search that finds the maximum number of events that occur in a single second on any given hour during the day using this

.. | bin _time span=1s | stats count by _time, name | bin _time span=1h | stats max(count) as mcount by _time, service | ...

this gives me a table of values that look like the following
Hour | Maximum
1 AM | 900
2 AM | 323
........ | .....

Instead I also want a third column which has the time that that event occurred as follows.

1 AM | 900 | September 1 2016, 12:34:06
2 AM | 323 | September 5 2016, 11:07:01
........ | .....

Any help would be appreciated.

0 Karma

somesoni2
Revered Legend

Try like this

.. | bin _time span=1s | stats count by _time, name | eval time=_time | bin _time span=1h | eventstats max(count) as mcount by _time, service | where mcount=count |eval time=strftime(time,"%+")
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...