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!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...