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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...