Splunk Search

How to edit my search to find events that did not occur right before a machine restart?

jpolcari
Communicator

I'd like to look for events of a Windows service stopping but ONLY if it did not occur while the machine was being rebooted. So far I have:

index=wineventlog  sourcetype=wineventlog:system (EventCode=7036 "Service Name" stopped) OR EventCode=6009
| transaction ComputerName startswith="EventCode=7036" endswith="EventCode=6009" maxspan=10m

EventCode 7036 is the service stopping while an EventCode 6009 occurs when the machine has just rebooted. This currently shows all the stops WITH a restart but I would like to find event 7036 when there was not a 6009 within about 10 minutes.

0 Karma
1 Solution

somesoni2
Revered Legend

Try this

index=wineventlog  sourcetype=wineventlog:system (EventCode=7036 "Service Name" stopped) OR EventCode=6009
| transaction ComputerName startswith="EventCode=7036" endswith="EventCode=6009" maxspan=10m keeporphan=t
| where duration>600 OR (mvcount(EventCode)=1 AND EventCode="7036")

View solution in original post

0 Karma

nickhills
Ultra Champion

try

 index=wineventlog  sourcetype=wineventlog:system (EventCode=7036 "Service Name" stopped) OR EventCode=6009 | transaction ComputerName startswith="EventCode=7036" endswith="EventCode=6009" maxspan=10m keeporphans=true|search _txn_orphan=1
If my comment helps, please give it a thumbs up!
0 Karma

somesoni2
Revered Legend

Try this

index=wineventlog  sourcetype=wineventlog:system (EventCode=7036 "Service Name" stopped) OR EventCode=6009
| transaction ComputerName startswith="EventCode=7036" endswith="EventCode=6009" maxspan=10m keeporphan=t
| where duration>600 OR (mvcount(EventCode)=1 AND EventCode="7036")
0 Karma

jpolcari
Communicator

Thanks very much! This looks like it works perfectly. Didn't realize you could keep the other results with keeporphans.

0 Karma
Get Updates on the Splunk Community!

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...

Adoption of Infrastructure Monitoring at Splunk

  Splunk's Growth Engineering team showcases one of their first Splunk product adoption-Splunk Infrastructure ...