Splunk Search

How to suppress first DELTA value?

anmcgill
Loves-to-Learn Lots

I am trying to alert on any processes where their CPU time is gaining 60 sec for every elapsed minute.  I am using the following search to calculate the delta in CPU time per process:

... | stats max(cpu_time_sec) as maxTime by PID _time
| delta maxTime as deltaTime 
| table _time PID deltaTime

I get the following output as an example (the above was filtered on a specific PID to get the below output):

_timePIDmaxTimedeltaTime
2021-03-29 13:28:44PID: 2691628572856
2021-03-29 13:29:45PID: 2691628570
2021-03-29 13:30:44PID: 2691628570
2021-03-29 13:31:45PID: 2691628570

 

The first value is always higher than it "should" be as the CPU time at that point is compared to a non-existent previous interval value unless I select a large enough time range that it predates when the process started.  I do not want to do this.

I am only strictly interested in getting the most recent deltas for the monitored processes and flagging those that have 60 sec of accumulated CPU time.  If I put a  where deltaTime>60 on my query I erroneously capture the first entry.

Any insights on how to accomplish this?

Labels (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Very simply you could add this after your table command

| streamstats c by PID
| where c>1

 which will exclude the first event for all PID.

 

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...