Splunk Search

Comparing results to identify values that have a certain value in previous records

Blueochotona
Engager

The two raw results are as follows : 

(1)

EventType="Device" Event="InstallProfileConfirmed" User="sysadmin" EnrollmentUser="hasubram" DeviceFriendlyName="blabla MacBook Air macOS 15.3.2 Q6LW" EventSource="Device" EventModule="Devices" EventCategory="Command" EventData="Profile=Apple macOS Apple Intelligence Restrictions" Event Timestamp: Mar 28 09:29:40

(2)

EventType="Device" Event="DeviceOperatingSystemChanged" User="sysadmin" EnrollmentUser="hasubram" DeviceFriendlyName="blabla MacBook Air macOS 15.3.2 Q6LW" EventSource="Device" EventModule="Devices" EventCategory="Assignment" EventData="Device=75639" Event Timestamp: Mar 28 09:29:29

Hoping to combine a search to identify (1)‘s DeviceFriendlyName="blabla MacBook Air macOS 15.3.2 Q6LW" which is a shared key between two results , as long (2) happens before (1) from a chronological experience.

I am already using the following to try and exclude certain results too : 

Index=*** <<Search Parameters>> NOT  DeviceFriendlyName IN (*15.3.0*,*15.3.1*)

 

Thank you 🙂

Labels (1)
0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @Blueochotona 

Have a look at the following, does this achieve what you're looking for?

index=*** <<Search Parameters>> NOT DeviceFriendlyName IN (*15.3.0*,*15.3.1*)
(
    (EventType="Device" Event="DeviceOperatingSystemChanged")
    OR
    (EventType="Device" Event="InstallProfileConfirmed")
)
| eval {Event}_time=_time
| stats
    latest(*_time) as *_time
    values(Event) as events by DeviceFriendlyName
    
| where MATCH(events, "DeviceOperatingSystemChanged") AND MATCH(events, "InstallProfileConfirmed") AND DeviceOperatingSystemChanged_time < InstallProfileConfirmed_time

Please let me know how you get on and consider adding karma to this or any other answer if it has helped.
Regards

Will

0 Karma

livehybrid
SplunkTrust
SplunkTrust

Here is a working example using makeresults too

| makeresults 
| eval _raw="EventType=\"Device\" Event=\"InstallProfileConfirmed\" User=\"sysadmin\" EnrollmentUser=\"hasubram\" DeviceFriendlyName=\"blabla MacBook Air macOS 15.3.2 Q6LW\" EventSource=\"Device\" EventModule=\"Devices\" EventCategory=\"Command\" EventData=\"Profile=Apple macOS Apple Intelligence Restrictions\" Event Timestamp: Mar 28 09:29:40" 
| append 
    [| makeresults 
    | eval _raw="EventType=\"Device\" Event=\"DeviceOperatingSystemChanged\" User=\"sysadmin\" EnrollmentUser=\"hasubram\" DeviceFriendlyName=\"blabla MacBook Air macOS 15.3.2 Q6LW\" EventSource=\"Device\" EventModule=\"Devices\" EventCategory=\"Assignment\" EventData=\"Device=75639\" Event Timestamp: Mar 28 09:29:29"] 
    | kv
| rex field=_raw "Event Timestamp: (?<EventTime>.+)$"    
| eval _time=strptime(EventTime, "%b %d %H:%M:%S")
| search DeviceFriendlyName="blabla MacBook Air macOS 15.3.2 Q6LW"
| eval {Event}_time=_time
| stats
    latest(*_time) as *_time
    values(Event) as events by DeviceFriendlyName
    
| where MATCH(events, "DeviceOperatingSystemChanged") AND MATCH(events, "InstallProfileConfirmed") AND DeviceOperatingSystemChanged_time < InstallProfileConfirmed_time

livehybrid_0-1743168301777.png

 

Please let me know how you get on and consider adding karma to this or any other answer if it has helped.
Regards

Will

Blueochotona
Engager

Very kewl 🙂 

Thank you 🙂 Will give it a shot for sure ! 

livehybrid
SplunkTrust
SplunkTrust

Excellent, let us know how you get on 🙂

Will

0 Karma
Get Updates on the Splunk Community!

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...