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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...