Splunk Search

Difference values from accumulated stat

lisheridan
Explorer

I have some statistic fields that are accumulated values over time. I want to chart the difference values between n and n-1 over time.

For example, number_segments looks like:
[1, 2, 5, 7, 10, ...]

I want to get a timechart of the difference n, n-1:
[1, 1, 3, 2, 3, ...]

How can I do this with the search language?

Tags (1)
0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

You'll need either delta or (more flexible and powerful) streamstats:

sourcetype=mydataseries | delta number_segments as diff | timechart diff

or

sourcetype=mydataseries 
| streamstats window=2 current=t global=f
  first(number_segments) as n last(number_segments) as n_minus_1
| eval diff=n_minus_1 - n 
| timechart diff

lisheridan
Explorer

this works, too, thanks!

0 Karma

Ayn
Legend
0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...