Security

Time Comparison of Unique Service Start/Stop Pairs

Krafter
Observer

Krafter_0-1674343647298.png

Hey all, requiring some assistance in tuning an out-of-box Splunk detection rule. 

Volume Shadow Copy services frequently enters the running/stopped state by itself. 
I wish to compare the lastTimeStamp of the running/stopped state of a unique service. 
Ideally, if the comparison is more than one hour, a field stoppedForMoreThanAnHour equals to True. 

How can I achieve this?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Replace the last line with:

| rex field=Message "The (?<service>.*?) service.^ (?<state>\w+) state"
| eval starttime=if(state="running", latestTimeStamp, null())
| eval stoptime=if(state="stopped", latestTimeStamp, null())
| stats values(starttime) as starttime values(stoptime) as stoptime by ComputerName service
| eval downtime=starttime - stoptime
| where downtime > 3600
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Replace the last two lines of the existing query with these.  They keep the most recent event for each computer only if it's a "stopped" event.  Then the timestamp is checked to see if it's more than an hour old.

| dedup computerName
| where match(_raw, "stopped") AND _time < relative_time(now(), "-1h")
---
If this reply helps you, Karma would be appreciated.
0 Karma

Krafter
Observer

Hey richgalloway! Thanks for the assistance. 

I don't think what you're proposing quite achieves what I wish to do, I likely explained it badly. 

I'm not looking for events where the stopped message was more than an hour ago. 

I'm looking for events where the difference in time between the "last stopped message" and "last started message" is more than an hour. 

0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...