Dashboards & Visualizations

How to add Search time range in table title

JIthesh_Kumar
Explorer

How can i add my search time range in my table title? 

Code: 

<title>Search from &lt;$SelectTime.earliest$&gt; to &lt;$SelectTime.latest$&gt;</title>

OutPut:

Search from <1691971200> to <1692057600>

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try adding something like this to your SelectTime input.

<change>
  <eval token="fromTime">strftime($SelectTime.earliest$,"%F %T")</eval>
  <eval token="toTime">strftime($SelectTime.latest$,"%F %T")</eval>
</change>

You then have two new tokens to use in your title.

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

These are times, they are just in internal format i.e. number of seconds since 1/1/1970.

You probably want to create tokens in the change handler of the time picker which evaluate tokens using the strftime() function.

0 Karma

JIthesh_Kumar
Explorer

How can i do that 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try adding something like this to your SelectTime input.

<change>
  <eval token="fromTime">strftime($SelectTime.earliest$,"%F %T")</eval>
  <eval token="toTime">strftime($SelectTime.latest$,"%F %T")</eval>
</change>

You then have two new tokens to use in your title.

JIthesh_Kumar
Explorer

Thanks for the replay , 

 

<done>
<eval token="earliest_time">strftime(relative_time(now(), $SelectTime.earliest$), "%d %b %T")</eval>
<eval token="latest_time">strftime(relative_time(now(), $SelectTime.latest$), "%d %b %T")</eval>
</done>

 

Now how can i convert it to GMT time 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Here's how you might do it in SPL

| eval time=strftime(_time,"%F %T %:::z")
| eval offset = substr(time,21,23)
| eval time_args = if( -1 * offset >= 0, "+".substr(offset,2,3), printf("%03d",-1 * offset))
| eval GMT = ceil(relative_time(_time,time_args."h"))
| convert ctime(GMT)

You might be able to get this to work with multiple eval token lines.

0 Karma
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!

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

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...