Splunk Search

search group by

cheeseng
New Member

I am doing a internal audit for splunk log, the query is following

index="_audit" action = edit_user NOT "search" |table timestamp user object operation

result:

timestamp                  user      object     operation
07-12-2012 15:07:53.419    admin     cheeseng   edit 
07-12-2012 15:07:53.419    admin     cheeseng   list 
07-12-2012 14:56:18.475    admin     admin      edit 
07-12-2012 14:56:18.475    admin     admin      list 
07-12-2012 14:56:18.475    admin     cheeseng   edit 

I am wondering how to group the result base on timestamp meaning same time of event should in a group
thanks

Tags (2)
0 Karma
1 Solution

Ayn
Legend

You could use stats and group by _time and user:

index="_audit" action=edit_user NOT search | stats values(object) as object,values(operation) as operation by user,_time

If you have events that happen at roughly the same time but not the exact same time, and you want to group them together anyway, you could use bucket to do that. For instance to group together events that happened within the same second:

index="_audit" action=edit_user NOT search | bucket _time span=1s | stats values(object) as object,values(operation) as operation by user,_time

View solution in original post

Ayn
Legend

You could use stats and group by _time and user:

index="_audit" action=edit_user NOT search | stats values(object) as object,values(operation) as operation by user,_time

If you have events that happen at roughly the same time but not the exact same time, and you want to group them together anyway, you could use bucket to do that. For instance to group together events that happened within the same second:

index="_audit" action=edit_user NOT search | bucket _time span=1s | stats values(object) as object,values(operation) as operation by user,_time
Get Updates on the Splunk Community!

.conf25 Registration is OPEN!

Ready. Set. Splunk! Your favorite Splunk user event is back and better than ever. Get ready for more technical ...

Detecting Cross-Channel Fraud with Splunk

This article is the final installment in our three-part series exploring fraud detection techniques using ...

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...