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!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...