Dashboards & Visualizations

Setting time frame values dynamically for splunk dashboard

Ashwin3
Engager

I have a use case where once a particular datetime is entered as input on the dashboard. Need to show search log results panel from two time frames side by side.  

say if the entered value is "07/06/2022:14:00:00"

1) -1hr from the time period entered (here in this case "07/06/2022:13:00:00 -"07/06/2022:14:00:00"

2) From the time period entered to till now (here in this case "07/06/2022:14:00:00 -NOW"

I am capturing the datetime entered as a timetoken

how to set another time token relative to the value entered on screen in dashboard? so that i can use both these tokens as earliest and latest for the first usecase.

Thanks

Labels (3)
0 Karma

diogofgm
SplunkTrust
SplunkTrust

You can use relative_time to eval tokens in your dashboard

e.g -1h

<eval token="new_token">relative_time($timeToken$,"-1h")</eval>

As for the now you can just use your time field as a earliest token in the search itself.

On both cases you'll probably need to use strftime to process your timestamp token format

From docs:

https://docs.splunk.com/Documentation/SplunkCloud/latest/Viz/tokens

------------
Hope I was able to help you. If so, some karma would be appreciated.
0 Karma

Ashwin3
Engager

Thank you. Will try once with this and confirm @diogofgm 

  <eval token="formatted_token">strptime($timeToken$,"%m/%d/%Y:%T")</eval>

 <eval token="new_token">relative_time($formatted_token$,"-1h")</eval>

I am trying with the above one but looks like <eval> is not getting accepted as child node for any of the form elements like <input>, <fieldset> etc. where can we place this <eval> step in UI form?

 

Also is there a way where we can accept datetime as input directly from dashboard. Currently i see a Time input but it does not allow to select a particular time. Hence am using text field for getting the datetime value.

 

Thanks.

0 Karma

diogofgm
SplunkTrust
SplunkTrust

Inside input > change tags. so it would be input > change > eval 

Check this part of the docs I shared before:
https://docs.splunk.com/Documentation/SplunkCloud/latest/Viz/tokens#Define_tokens_for_conditional_op...

You could use a time picker since it already creates tokens for you. if you name your time picker timepicker you'll have $timepicker.earliest$ and $timepicker.latest$ and use these to then eval the new tokens 

------------
Hope I was able to help you. If so, some karma would be appreciated.
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Build the Future of Agentic AI: Join the Splunk Agentic Ops Hackathon

AI is changing how teams investigate incidents, detect threats, automate workflows, and build intelligent ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...