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!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...