Splunk Search

calculating average

pmr
Explorer

Need some help on search string to calculate 10 minute average and generate alert.
say for example Virtual memory usage 10 minute average > 10000 generate an alert. How can we calculate 10 minute average ?
this would be from a table event so need to use multikv. sample event below :

USER               PID   PSR   pctCPU       CPUTIME  pctMEM     RSZ_KB     VSZ_KB   TTY      S       ELAPSED  COMMAND             ARGS
root                 1     1      0.0      00:00:16     0.0        788      10384   ?        S   19-08:11:30  init                [3]
root                 2     1      0.0      00:00:00     0.0          0          0   ?        S   19-08:11:30  [kthreadd]          <noArgs>
root                 3     0      0.0      00:00:00     0.0          0          0   ?        S   19-08:11:30  [migration/0]       <noArgs>
root                 4     0      0.0      00:00:00     0.0          0          0   ?        S   19-08:11:30  [ksoftirqd/0]       <noArgs>
root                 5     0      0.0      00:00:26     0.0          0          0   ?        S   19-08:11:30  [events/0]          <noArgs>
root                 6     0      0.0      00:00:00     0.0          0          0   ?        S   19-08:11:30  [cpuset]            <noArgs

thanks
pmr

Tags (1)
0 Karma

Masa
Splunk Employee
Splunk Employee

The sample is ps output. Assuming you get the ps output every minutes or so. Virtual memory usage is VSZ_KB per PID in the event. You can run the following search every 10 minutes and set the alert when there is events more than one;

sourcetype=ps earliest=-11m@m latest=-1m@m
   | multikv fields VSZ_KB PID
   | chart avg(VSZ_KB) AS AvgSizeKB by PID 
   | where AvgSizeKB > 10000 
   | sort - AvgSizeKB
0 Karma

pmr
Explorer

thank you.. works perfect.

-pmr

0 Karma

pmr
Explorer

Folks,
Any help on this ?

-pmr

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 ...