<?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: Visualizations: Can eval tag (calculating token values) be used inside init, selection, progress or done? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426760#M122261</link>
    <description>&lt;P&gt;@arkadyz71, your issue is not quite clear. However, I do want to mention that &lt;CODE&gt;&amp;lt;eval&amp;gt;&lt;/CODE&gt; behavior is slightly different in eval command in searches and as &lt;CODE&gt;&amp;lt;eval&amp;gt;&lt;/CODE&gt; tag in Simple XML dashboard. Refer to dashboard: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Define_token_filtering_and_formatting"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Define_token_filtering_and_formatting&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Related to your question, Do you want to display the Earliest and Latest Time as String Time in Panel Title? Do you also want to use the time as &lt;CODE&gt;&amp;lt;selection&amp;gt;&lt;/CODE&gt; for timechart when time input has any change?&lt;/P&gt;

&lt;P&gt;Please refer to one of my previous answers which Sets Earliest and Latest Time (Epoch and String Time) based on (1) Splunk job's token &lt;CODE&gt;$job.earliestTime$&lt;/CODE&gt; and &lt;CODE&gt;$job.latestTime$&lt;/CODE&gt; and (2) using &lt;CODE&gt;addinfo&lt;/CODE&gt; command by running dummy search. &lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/578984/running-one-of-two-searches-based-on-time-picker-s.html"&gt;https://answers.splunk.com/answers/578984/running-one-of-two-searches-based-on-time-picker-s.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jun 2018 17:54:35 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-06-01T17:54:35Z</dc:date>
    <item>
      <title>Visualizations: Can eval tag (calculating token values) be used inside init, selection, progress or done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426759#M122260</link>
      <description>&lt;P&gt;All this is happening in Splunk 6.6.2:&lt;/P&gt;

&lt;P&gt;I have a relatively complex form, with a timechart and a drilldown from it selection to the data table below it. I wanted to show the time interval in a table title, and tried using &lt;CODE&gt;$start$&lt;/CODE&gt; and &lt;CODE&gt;$end$&lt;/CODE&gt; (saving them in some external tokens within &lt;CODE&gt;&amp;lt;selection&amp;gt;&lt;/CODE&gt; - to be used in &lt;CODE&gt;&amp;lt;earliest&amp;gt;&lt;/CODE&gt; and &lt;CODE&gt;&amp;lt;latest&amp;gt;&lt;/CODE&gt; tags of the data table search, as well as displayed in the title) for that. I also tried to use $job.earliestTime$ and $job.latestTime$ from inside &lt;CODE&gt;&amp;lt;progress&amp;gt;&lt;/CODE&gt; tag to save them into the tokens referenced in the title.&lt;/P&gt;

&lt;P&gt;Unfortunately, this shows the time either as &lt;CODE&gt;-8h&lt;/CODE&gt; (if I pick "8 hours ago" from the time picker and don't make a selection within the time chart) or as an integer like &lt;CODE&gt;1527835260&lt;/CODE&gt;. "No big deal", I thought and slapped an &lt;CODE&gt;&amp;lt;eval token="earliest_for_display"&amp;gt;strftime($start$,"%F %T")&amp;lt;/eval&amp;gt;&lt;/CODE&gt; within the timechart's &lt;CODE&gt;&amp;lt;selection&amp;gt;&lt;/CODE&gt;. Then I tried the same with &lt;CODE&gt;$job.earliestTime$&lt;/CODE&gt; inside data table search's &lt;CODE&gt;&amp;lt;progress&amp;gt;&lt;/CODE&gt; instead of &lt;CODE&gt;$start$&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;It seems that the eval never even tried to execute. I ended up pre-setting those tokens with "Earliest: not set yet" and "Latest: not set yet" within the form's &lt;CODE&gt;&amp;lt;init&amp;gt;&lt;/CODE&gt; - and they never changed.&lt;/P&gt;

&lt;P&gt;As a side note - might be helpful to some: simple &lt;CODE&gt;strftime&lt;/CODE&gt; will not work with relatives like &lt;CODE&gt;@d&lt;/CODE&gt;, &lt;CODE&gt;-24h&lt;/CODE&gt; or &lt;CODE&gt;now&lt;/CODE&gt;, so I came up with the following construct:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;eval token="earliest_for_display"&amp;gt;strftime(case(
$job.earliestTime$=="now",now(),
match(tostring($job.earliestTime$),"^[-+@]"),relative_time(now(),$job.earliestTime$),
match(tostring($job.earliestTime$),"^\d{4}-"),strptime($job.earliestTime$,"%FT%T.%3N%:z"),
1==1,$job.earliestTime$),"%F %T")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That &lt;CODE&gt;"^\d{4}-"&lt;/CODE&gt; is for the times I get from &lt;CODE&gt;&amp;lt;selection&amp;gt;&lt;/CODE&gt; - they seem to be returned in that &lt;CODE&gt;"%FT%T.%3N%:z"&lt;/CODE&gt; format.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 15:41:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426759#M122260</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2018-06-01T15:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Visualizations: Can eval tag (calculating token values) be used inside init, selection, progress or done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426760#M122261</link>
      <description>&lt;P&gt;@arkadyz71, your issue is not quite clear. However, I do want to mention that &lt;CODE&gt;&amp;lt;eval&amp;gt;&lt;/CODE&gt; behavior is slightly different in eval command in searches and as &lt;CODE&gt;&amp;lt;eval&amp;gt;&lt;/CODE&gt; tag in Simple XML dashboard. Refer to dashboard: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Define_token_filtering_and_formatting"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Viz/tokens#Define_token_filtering_and_formatting&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Related to your question, Do you want to display the Earliest and Latest Time as String Time in Panel Title? Do you also want to use the time as &lt;CODE&gt;&amp;lt;selection&amp;gt;&lt;/CODE&gt; for timechart when time input has any change?&lt;/P&gt;

&lt;P&gt;Please refer to one of my previous answers which Sets Earliest and Latest Time (Epoch and String Time) based on (1) Splunk job's token &lt;CODE&gt;$job.earliestTime$&lt;/CODE&gt; and &lt;CODE&gt;$job.latestTime$&lt;/CODE&gt; and (2) using &lt;CODE&gt;addinfo&lt;/CODE&gt; command by running dummy search. &lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/578984/running-one-of-two-searches-based-on-time-picker-s.html"&gt;https://answers.splunk.com/answers/578984/running-one-of-two-searches-based-on-time-picker-s.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2018 17:54:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426760#M122261</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-06-01T17:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Visualizations: Can eval tag (calculating token values) be used inside init, selection, progress or done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426761#M122262</link>
      <description>&lt;P&gt;Thanks for the link back to your previous answer - voted that up. For some reason, &lt;CODE&gt;strptime(strftime($job.earliestTime$,...),...)&lt;/CODE&gt; failed to work for me, so I went with the &lt;CODE&gt;| addinfo&lt;/CODE&gt; option. That did work - especially nice because &lt;CODE&gt;addinfo&lt;/CODE&gt; is producing times in time and not string format, so there is no guessing what to tell &lt;CODE&gt;strptime&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 15:02:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426761#M122262</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2018-06-12T15:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Visualizations: Can eval tag (calculating token values) be used inside init, selection, progress or done?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426762#M122263</link>
      <description>&lt;P&gt;@arkadyz1,I am glad you found one of the options useful, you can accept this answer to mark this question as answered!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 15:09:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Visualizations-Can-eval-tag-calculating-token-values-be-used/m-p/426762#M122263</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-06-12T15:09:14Z</dc:date>
    </item>
  </channel>
</rss>

