Splunk Search

how to get the hourly increase or decrease of a numeric field (hour 1: 10, hour 2: 20 --> increase = 10)

jschikar
Engager

Hi,

i have hourly values and i want to see the difference to the hour before.
So instead of hour 1: 10€, hour 2: 20€, hour 3: 10€
I want the increase / decrease: hour 2: +10 hour 3: -10

I imagined this should be possible with a calculated field maybe?

Thanks in advance!

0 Karma
1 Solution

DalJeanis
SplunkTrust
SplunkTrust

This generates some test data -

| makeresults | eval myfield="10 20 15 30 18 40" | makemv myfield | mvexpand myfield 
| streamstats count as hour | eval _time = _time + 3600*hour | bin _time span=1h

This is what you want -

| delta myfield as difference
| table _time hour myfield difference

With this sample output -

_time                         hour      myfield   difference
2017-02-16T20:00:00.000+0000  1         10                  
2017-02-16T21:00:00.000+0000  2         20        10        
2017-02-16T22:00:00.000+0000  3         15        -5        
2017-02-16T23:00:00.000+0000  4         30        15        
2017-02-17T00:00:00.000+0000  5         18        -12       
2017-02-17T01:00:00.000+0000  6         40        22    

View solution in original post

DalJeanis
SplunkTrust
SplunkTrust

This generates some test data -

| makeresults | eval myfield="10 20 15 30 18 40" | makemv myfield | mvexpand myfield 
| streamstats count as hour | eval _time = _time + 3600*hour | bin _time span=1h

This is what you want -

| delta myfield as difference
| table _time hour myfield difference

With this sample output -

_time                         hour      myfield   difference
2017-02-16T20:00:00.000+0000  1         10                  
2017-02-16T21:00:00.000+0000  2         20        10        
2017-02-16T22:00:00.000+0000  3         15        -5        
2017-02-16T23:00:00.000+0000  4         30        15        
2017-02-17T00:00:00.000+0000  5         18        -12       
2017-02-17T01:00:00.000+0000  6         40        22    

jschikar
Engager

That's exactly what i want!
Thanks very much, I didn't come across the delta function 🙂

0 Karma

DalJeanis
SplunkTrust
SplunkTrust

No problem. There's a lot of splunk verbs I don't know yet. Every week I learn another one or two, or a better way to use the ones I DO know...

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...