Dashboards & Visualizations

Subtracting time charts

priyangshupal
Engager

I have a timechart from the command timechart span=1d count by skill1 which looks like this:

_timeVALUE1VALUE2VALUE3VALUE4
2021-09-15772431728
2021-09-16801046522

 

And another timechart from the command timechart span=1d count by skill2 which looks like this:

_timeVALUE1VALUE2VALUE3VALUE4
2021-09-15702001012
2021-09-1656875411

 

I want to create a new timechart which should have skill1's values - skill2's values. As follows:

_timeVALUE1VALUE2VALUE3VALUE4
2021-09-15743716
2021-09-1614171111

 

I tried using the command:

 

timechart span=1d count by skill1-skill2

 

But it won't work.

 

Any suggestions on how to create the new timechart?

Labels (3)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

Alternatively if you can share your data selection part of the search, it can probably be done using subsearches to join the two data sets together.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

You can do this type of timechart with eval and then calc the differences afterwards, but that my not work unless you know and can code in all the values of skill

| makeresults count=1000
| eval _time=_time-(random() % 7)*86400
| eval skill1=mvindex(split("Value1,Value2,Value3,Value4",","), random() % 4)
| eval skill2=mvindex(split("Value1,Value2,Value3,Value4",","), random() % 4)
| timechart span=1d sum(eval(if(skill1="Value1", 1, 0))) as s1v1 sum(eval(if(skill1="Value2", 1, 0))) as s1v2 sum(eval(if(skill1="Value3", 1, 0))) as s1v3 sum(eval(if(skill1="Value4", 1, 0))) as s1v4 sum(eval(if(skill2="Value1", 1, 0))) as s2v1 sum(eval(if(skill2="Value2", 1, 0))) as s2v2 sum(eval(if(skill2="Value3", 1, 0))) as s2v3 sum(eval(if(skill2="Value4", 1, 0))) as s2v4
| eval v1=s1v1-s2v1, v2=s1v2-s2v2, v3=s1v3-s2v3, v4=s1v4-s2v4
| table _time v*

Just paste in this to the search window

 

0 Karma

priyangshupal
Engager

Hi @bowesmana 

This is producing results, but the difference is wrong

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 ...