Splunk Search

Combine events based on timestamps in event

manuarora12
New Member

I have events as following
Category=a starttime="2017-11-14 05:25:22"
Category=b starttime="2017-11-14 05:29:22"
Category=b starttime="2017-11-14 04:28:18"
Category=c starttime="2017-11-14 03:22:21"
Category=a starttime="2017-11-14 06:21:28"

I want all events count by Category by hour of occurance as per starttime. _time might be completely different from starttime.

So results should say something like

Hour Category Count
5 a 1
b 1
6 b 1

0 Karma

niketn
Legend

@manuarora12, you can try the following:

<YourBaseSearch>
|  eval _time=strptime(starttime,"%Y-%m-%d %H:%M:%S")
|  timechart span=1h count by Category
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

knielsen
Contributor

What about

<your search> | rex field=starttime "\S{10}\s(?<Hour>\d\d)" | stats count by Hour, Category

Regards,
Kai.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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