Dashboards & Visualizations

Search time range based on epoch token from drilldown, how can I use my epoch token to set the time ranges in my panels?

TalNiv
New Member

I have a dashboard which received a token named "time" by drilldown, which stores a specific time in epoch. 

Now I want the searches in my dashboard to have a time range based on this epoch value. 

I tried to use this token in "earliest" and "latest",  i.e, <earliest>$time$</earliest>.

I worked only when I put the token as is, but not with any kind of simple arithmetic like <earliest>$time$ - 100000 </earliest>.

How can I use my epoch token to set the time ranges in my panels? 

Labels (4)
0 Karma

danspav
SplunkTrust
SplunkTrust

Hi @TalNiv ,

The easiest way is how @gcusello said - update the original dashboard to create two tokens for earliest / latest.

You can add this to the section where you create the $time$ token in the original dashboard:
<eval token="earliest">tonumber($time$) - 10000</eval>

If you don't have access to that dashboard there aren't many options. AFAIK you cannot use URL sourced tokens in the <init> section of your dashboard to do the same eval tag.

One very roundabout way is to create a dummy search, and create tokens off that. E.g. put this at the top of your dashboard under the label section:

<search>
<query>|makeresults | eval earliest=tonumber($time$) - 100000, latest=$time$</query>
<done>
<set token="earliest">$result.earliest$</set>
<set token="latest">$result.latest$</set>
</done>
</search>

Now you can use $earliest$ and $latest$ in your searches.

gcusello
SplunkTrust
SplunkTrust

Hi @TalNiv,

in the main dashboard create two fields earliest and latest (both in epochtime) and then pass them in drilldown.

Ciao.

Giuseppe

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