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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...