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
Legend

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
Legend

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
Legend

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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...