Splunk Search

Calculate difference between values on timechart

dataisbeautiful
Communicator

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
Communicator

Thank you @gcusello, that worked

0 Karma
Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...