Dashboards & Visualizations

Can I use time range tokens in an eval expression?

aaloisi
Explorer

Hi all,

I am trying to use the boundaries of the time range picker in my dashboard to calculate a value in my search query. let me explain my situation:

I am calculating on / off durations for different pieces of equipment. I receive messages when there is a change in state so each row in the table is a change of state. To calculate the duration I use delta on time to get the difference in time. See a results table example below:

Search time range: 11:00 am - 1:00pm, _time is in descending order by equipment
alt text

Where I run into an issue is when the equipment changes. A delta between the last fan event and the first heater event would generate a duration that does not make sense. This is where the time range picker range comes in. I want the duration for the highlighted event to be the time of the event to the latest boundary of the time range picker. Like below:

| eval duration = if(equipchange=NO, duration, $time_token.latest$ - duration) 

I'm not sure if this is possible since I have no been able to get it to work. Any suggestions would be greatly appreciated! Let me know if I can offer more clarification.

0 Karma
1 Solution

to4kawa
Ultra Champion

use info_max_time of addinfo

View solution in original post

to4kawa
Ultra Champion

use info_max_time of addinfo

aaloisi
Explorer

that is exactly what I needed, thank you to4kawa! Here is what I wrote using this solution.

| addinfo
| eval duration = if(equipchange=NO, duration, info_max_time - _time) 
0 Karma

niketn
Legend

@aaloisi please accept the answer if your issue is resolved!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...