Dashboards & Visualizations

How to enter selected Time period in the Chart title in a Dashboard?

Norrmor
Loves-to-Learn

Hi there,

I have managed to enter other fields in Chart title, but I fail to get the selected time period visible with a dynamic variable in the title of a Chart.

So, I can do this chart title: 

  • Time chart of Users and Journal notes ($care_unit_tok$)
  • Which after Care Unit selection = ASIH Botkyrka results in this title:  
    Antal användare och journalanteckningar (| where (care_unit = "ASIH Botkyrka"))

But I fail to do similar action with time_tok, e.g. like this: 

  • Time chart of Users and Journal notes ($time_tok$)
  • But even if I have made a time selection which I can see in the filter as Jul 2023,
    I only get this text over the Chart, without any time period displayed: 
    Time chart of Users and Journal notes

Thanks for any ideas on how to solve this. 

 

Labels (1)
0 Karma

Norrmor
Loves-to-Learn

And when I enter your phrase inside the search code of that report I got this error: 

Norrmor_1-1691765012536.png

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try adding the line to the change handler for the time input widget

0 Karma

Norrmor
Loves-to-Learn

Thanks again, but that did not work either in the title:

Norrmor_0-1691764655596.png



I have also tried $form.time_tok$   (which worked wonders for other fields like $form.care_unit_tok$)
to no avail (-> empty result). 

I have also tried $form.time$    
(-> empty result)


0 Karma

Norrmor
Loves-to-Learn

Now I found in the source code: 

| stats count as cnt by Tenant</query>
<earliest>$time_tok.earliest$</earliest>
<latest>$time_tok.latest$</latest>
</search>

and further down:

<input type="time" token="time_tok">
<label>Period</label>
<default>
<earliest>-1y@y</earliest>
<latest>now</latest>
</default>
</input>

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

<eval token="date">strftime($time_tok.earliest$,"%m %Y")</eval>
0 Karma

Norrmor
Loves-to-Learn

Basically, I want the time for the time period of the search interval.
(Could be as "from-to", or as a dedicated month or year. I am not picky)

I do not need the time for the actual search results. 

0 Karma

Norrmor
Loves-to-Learn

Hi, my answer disappeared. Sorry. 

I am using the standard time selection filter in Splunk:

Norrmor_0-1691759351850.png

 

I tried your variables on another Chart: 
Statuses ($time_tok.earliest$ - $time_tok.latest$)

Which rendered this result (which is as you say useless to me and the users): 
Statuses (1688169600 - 1690848000)

0 Karma

Norrmor
Loves-to-Learn

Hi @ITWhisperer, thanks!
I am actually updating a Dashboard created by my previous colleague.
So I have this filter already set up like this.

 

Norrmor_0-1691757923231.png

When I use the dashboard, the standard Time period selection comes up like this: 

Norrmor_1-1691758040936.png

And then on the filter it looks like this in the Time Period selection filter: 

Norrmor_2-1691758143249.png

 


Does that help? 
I mean, somehow Splunk gets a value that it shows in the selection filter. 

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Probably going to need a bit more information

How is time_tok set? If you are using a time input widget, you can get $time_tok.earliest$ and $time_tok.latest$ as the earliest and latest values chosen.

However, I suspect this may not be in the format you want.

You could either use the change handler (if you have a Classic Dashboard) to evaluate a new token based on the either the earliest or latest time selected, or use the done handler for the panel search and evaluate a token based on the (first row of the) result of the search.

0 Karma
Get Updates on the Splunk Community!

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...