<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to format &amp;quot;snap to time&amp;quot; to string in dashboard panel title. in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312874#M20031</link>
    <description>&lt;P&gt;Second attempt...&lt;BR /&gt;
We need to check if the timepicker variable is an Epoch number or a Splunk artifact like “-7d@d” or “now”.&lt;BR /&gt;
If the variable is an Epoch number, we convert it to a date using strftime.&lt;BR /&gt;
If the variable is a String, we need to convert it into an Epoch number using relative_time, then into a date.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      &amp;lt;earliest&amp;gt;$command_token.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$command_token.latest$&amp;lt;/latest&amp;gt;
      &amp;lt;progress&amp;gt;
        &amp;lt;eval token="allCommandsEarliestLabel"&amp;gt;
          if(isnum($command_token.earliest$),strftime($command_token.earliest$,"%d/%m/%Y %H:%M:%S"),strftime(relative_time(now(), $command_token.earliest$),"%m/%d/%Y %H:%M:%S"))
        &amp;lt;/eval&amp;gt;
        &amp;lt;eval token="allCommandsLatestLabel"&amp;gt;
          if(isnum($command_token.latest$),strftime($command_token.latest$,"%m/%d/%Y %H:%M:%S"),strftime(relative_time(now(), "@sec"),"%m/%d/%Y %H:%M:%S"))
        &amp;lt;/eval&amp;gt;
      &amp;lt;/progress&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Oct 2018 22:12:57 GMT</pubDate>
    <dc:creator>rgaffur</dc:creator>
    <dc:date>2018-10-30T22:12:57Z</dc:date>
    <item>
      <title>How to format "snap to time" to string in dashboard panel title.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312870#M20027</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I am designing a dashboard that will use a timer pick to build search. I would like to show in the panel title the time in the same format as any Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;7/6/17 9:00:00.000 AM to 7/13/17 9:19:00.000 AM
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I add the timer in the title I am getting the "snap to time" format:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Between $timer.earliest$ and $timer.latest$

=

Between -7d@h and now
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there anyway I can format it to string? I tried feel combinations, but they didn't work:&lt;/P&gt;

&lt;P&gt;1st:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Select Desired Time of oom-killer Invocation&amp;lt;/title&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Between strftime($timer.earliest$,"%c") and strftime($timer.latest$,"%c")&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;


Output:

Between strftime(-7d@h,"%c") and strftime(now,"%c")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2nd:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;input type="time" token="timer" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Timeframe&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-7d@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;unset token="SearchHost"&amp;gt;&amp;lt;/unset&amp;gt;
        &amp;lt;unset token="tssnservice"&amp;gt;&amp;lt;/unset&amp;gt;
        &amp;lt;eval token="searliest"&amp;gt;strftime(earliest,"%c")&amp;lt;/eval&amp;gt;
        &amp;lt;eval token="slatest"&amp;gt;strftime(latest,"%c")&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
...

      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Between $searliest$ and $slatest$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
...


OUTPUT:

Between Invalid date and Invalid date
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;input type="time" token="timer" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Timeframe&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-7d@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;unset token="SearchHost"&amp;gt;&amp;lt;/unset&amp;gt;
        &amp;lt;unset token="tssnservice"&amp;gt;&amp;lt;/unset&amp;gt;
        &amp;lt;eval token="searliest"&amp;gt;'strftime(earliest,"%c")'&amp;lt;/eval&amp;gt;
        &amp;lt;eval token="slatest"&amp;gt;'strftime(latest,"%c")'&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
...
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Between $searliest$ and $slatest$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
...

OUTPUT:

Between $searliest$ and $slatest$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there any other option?&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;

&lt;P&gt;Gerson&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 17:02:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312870#M20027</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2017-07-13T17:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to format "snap to time" to string in dashboard panel title.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312871#M20028</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;label&amp;gt;Time Range:&amp;lt;/label&amp;gt;
  &amp;lt;default&amp;gt;
    &amp;lt;earliestTime&amp;gt;-1d@d&amp;lt;/earliestTime&amp;gt;
    &amp;lt;latestTime&amp;gt;@d&amp;lt;/latestTime&amp;gt;
  &amp;lt;/default&amp;gt;
  &amp;lt;change&amp;gt;
      &amp;lt;!-- use predefined input tokens to set --&amp;gt;
      &amp;lt;!-- tokens for the selected label and value --&amp;gt;
      &amp;lt;set token="date_label"&amp;gt;$label$&amp;lt;/set&amp;gt;
      &amp;lt;set token="earliest_tok"&amp;gt;$value$&amp;lt;/set&amp;gt;
  &amp;lt;/change&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 18:52:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312871#M20028</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-07-13T18:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to format "snap to time" to string in dashboard panel title.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312872#M20029</link>
      <description>&lt;P&gt;No, that is not what the timer pick sets. it sets 2 variables:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;        &amp;lt;earliest&amp;gt;-7d@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The provided code works for dropdown lists.&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 01:17:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312872#M20029</guid>
      <dc:creator>GersonGarcia</dc:creator>
      <dc:date>2017-07-14T01:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to format "snap to time" to string in dashboard panel title.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312873#M20030</link>
      <description>&lt;P&gt;First attempt...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;title&amp;gt;All Commands Last from $allCommandsEarliestLabel$ to $allCommandsLatestLabel$&amp;lt;/title&amp;gt;
  &amp;lt;chart id="allCommandMaster"&amp;gt;
    &amp;lt;search id="passBaseSearch"&amp;gt;
      &amp;lt;query&amp;gt;index=...|stats count by command&amp;lt;/query&amp;gt;
      &amp;lt;earliest&amp;gt;$command_token.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$command_token.latest$&amp;lt;/latest&amp;gt;
      &amp;lt;progress&amp;gt;
        &amp;lt;eval token="allCommandsEarliestLabel"&amp;gt;if(isnum($command_token.earliest$),strftime($command_token.earliest$,"%d/%m/%Y %H:%M:%S"),$command_token.earliest$)&amp;lt;/eval&amp;gt;
        &amp;lt;eval token="allCommandsLatestLabel"&amp;gt;if(isnum($command_token.latest$),strftime($command_token.latest$,"%d/%m/%Y %H:%M:%S"),$command_token.latest$)&amp;lt;/eval&amp;gt;
      &amp;lt;/progress&amp;gt;
    &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 15:56:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312873#M20030</guid>
      <dc:creator>rgaffur</dc:creator>
      <dc:date>2018-10-30T15:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to format "snap to time" to string in dashboard panel title.</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312874#M20031</link>
      <description>&lt;P&gt;Second attempt...&lt;BR /&gt;
We need to check if the timepicker variable is an Epoch number or a Splunk artifact like “-7d@d” or “now”.&lt;BR /&gt;
If the variable is an Epoch number, we convert it to a date using strftime.&lt;BR /&gt;
If the variable is a String, we need to convert it into an Epoch number using relative_time, then into a date.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;      &amp;lt;earliest&amp;gt;$command_token.earliest$&amp;lt;/earliest&amp;gt;
      &amp;lt;latest&amp;gt;$command_token.latest$&amp;lt;/latest&amp;gt;
      &amp;lt;progress&amp;gt;
        &amp;lt;eval token="allCommandsEarliestLabel"&amp;gt;
          if(isnum($command_token.earliest$),strftime($command_token.earliest$,"%d/%m/%Y %H:%M:%S"),strftime(relative_time(now(), $command_token.earliest$),"%m/%d/%Y %H:%M:%S"))
        &amp;lt;/eval&amp;gt;
        &amp;lt;eval token="allCommandsLatestLabel"&amp;gt;
          if(isnum($command_token.latest$),strftime($command_token.latest$,"%m/%d/%Y %H:%M:%S"),strftime(relative_time(now(), "@sec"),"%m/%d/%Y %H:%M:%S"))
        &amp;lt;/eval&amp;gt;
      &amp;lt;/progress&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Oct 2018 22:12:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-format-quot-snap-to-time-quot-to-string-in-dashboard/m-p/312874#M20031</guid>
      <dc:creator>rgaffur</dc:creator>
      <dc:date>2018-10-30T22:12:57Z</dc:date>
    </item>
  </channel>
</rss>

