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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...