Splunk Search

Calculate difference between values on timechart

dataisbeautiful
Explorer

Hi all

I'd like to plot the difference between two values on a timechart

Example data:

_timeab
t101
t+1s111.5
t+2s122

 

Expected resulting data

timeabc
t1019
t+1s111.59.5
t+2s12210

 

I'm using the query

 

 

 

index=indx sourcetype=src (Instrument="a" OR Instrument="b")
| eval c = a - b
| timechart values(a) values(b) values(c) span=1s

 

 

 

Any ideas where I'm going wrong?

Labels (2)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @dataisbeautiful,

try to add eval after the timechart:

index=indx sourcetype=src (Instrument="a" OR Instrument="b")
| timechart values(a) values(b) span=1s
| eval c = a - b

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @dataisbeautiful,

try to add eval after the timechart:

index=indx sourcetype=src (Instrument="a" OR Instrument="b")
| timechart values(a) values(b) span=1s
| eval c = a - b

Ciao.

Giuseppe

dataisbeautiful
Explorer

Thank you @gcusello, that worked

0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...