Splunk Search

Grouping fields in a search: How do I apply conditional logic to the results to assign new values?

katzr
Path Finder

I have a table that has UserID, device, and classification (1,2,3). A UserID can have multiple devices and a device can have multiple UserIDs. As of now, the row of data has a classification based on other factors for each row containing a device and UserID.

This means a userID may have many different classifications for each of their devices. I want to change the classification for each user to the highest classification. For example: a UserID has 4 devices with a classification of 1,2,2,3. I want to change the classification for each of these to 3 because that is the max of the classification for that UserID.

I need help with the logic of this and how I can group the UserID to find the number of devices per UserID and then use if statements to change the classification?

0 Karma

DalJeanis
Legend

Do you want every row for each user updated to have the highest classification on any row? or are you just wanting a search that brings back the highest classification for each user?

This gives you a single record for each UserID, with a list of their devices, and the highest classification

your search that brings UserID, device, classification
| stats list(device) as device max(classification) as classification by UserID

This gives you each record that you currently have, marked with the highest classification that user has.

your search that brings UserID, device, classification
 | eventstats max(classification) as classification by UserID

This gives you one record for each combination of userID and device, marked with the highest classification that user has.

your search that brings UserID, device, classification
 | eventstats max(classification) as maxclass by UserID
 | stats max(maxclass) as classification by UserID device  
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...