Splunk Search

Problems using delta function

jedatt01
Builder

I'm trying to get the delta between records on a particular field, but when I add the delta function to my search it comes back with results but the new delta field is not created. I suspect it has to do with my source field. It's an energy reading (ex. 1000 kWH). I've used the trim function to cut off the kWH and just leave the number, but it's not working. I tried to use delta on another field and it works fine. Also, when I do pick a field that shows the delta, it's always a negative value, since my field is a counter like an odometer, shouldn't it be a positive value?

sourcetype="Energy_Meter" | eval TE=rtrim(Total_Energy, "kWH") | delta TE p=5 AS delta

Tags (2)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

Could this be related to the fact that events come back newest-first? If you have a reading from your power meter, it tends to increase over time, and thus the delta would be negative.

day    meter    delta
4      123  
3      111      -12
2      107      -4
1      101      -6
etc etc

Try reversing search results with reverse in that case.

EDIT: had days in the wrong order.... fixed it.

Hope this helps,

Kristian

View solution in original post

kristian_kolb
Ultra Champion

Could this be related to the fact that events come back newest-first? If you have a reading from your power meter, it tends to increase over time, and thus the delta would be negative.

day    meter    delta
4      123  
3      111      -12
2      107      -4
1      101      -6
etc etc

Try reversing search results with reverse in that case.

EDIT: had days in the wrong order.... fixed it.

Hope this helps,

Kristian

jedatt01
Builder

Turns out I was forgetting a space in my rtrim. It should have been eval TE=rtrim(Total_Energy, " kWH")
Thanks!

0 Karma

jedatt01
Builder

Half way fixed. The reverse worked. Any idea why I can't do a delta on the field that I used rtrim on?

eval TE=rtrim(Total_Energy, "kWH") | delta TE p=5 AS delta

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...