<?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 Modify search time based on dropdown selection in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344106#M22388</link>
    <description>&lt;P&gt;I have a dropdown selection for a Policy field. I want to be able modify the search time based on the policy selected in the dropdown. &lt;/P&gt;

&lt;P&gt;The drop down has 3 static options and depending on what is selected the time of the search needs to be either the last 60 mins or the last 7 days. I am not sure on how to modify the time parameters on the search. I tried inserting the earliest/latest info into the PolicyTOK but had issues getting it to behave correctly &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;input type="dropdown" token="PolicyTOK"&amp;gt;
        &amp;lt;label&amp;gt;Details&amp;lt;/label&amp;gt;
        &amp;lt;choice value="untagged"&amp;gt;Untagged&amp;lt;/choice&amp;gt;
        &amp;lt;choice value="stopped"&amp;gt;Stopped&amp;lt;/choice&amp;gt;
        &amp;lt;choice value="terminated"&amp;gt;Terminated&amp;lt;/choice&amp;gt;
        &amp;lt;default&amp;gt;untagged&amp;lt;/default&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=xxx sourcetype=_json "message.Records{}.Sns.Message.policy.name"="$PolicyTOK$" | spath output=AccountId path=message.Records{}.Sns.Message.account_id | spath output=account path=message.Records{}.Sns.Message.account | spath output=region path=message.Records{}.Sns.Message.region | spath output=InstanceId path=message.Records{}.Sns.Message.resources{}.InstanceId |dedup AccountId | table account AccountId region InstanceId  | sort AccountId&amp;lt;/query&amp;gt;
        &amp;lt;earliest&amp;gt;-60m@m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Mar 2018 16:46:16 GMT</pubDate>
    <dc:creator>a238574</dc:creator>
    <dc:date>2018-03-09T16:46:16Z</dc:date>
    <item>
      <title>Modify search time based on dropdown selection</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344106#M22388</link>
      <description>&lt;P&gt;I have a dropdown selection for a Policy field. I want to be able modify the search time based on the policy selected in the dropdown. &lt;/P&gt;

&lt;P&gt;The drop down has 3 static options and depending on what is selected the time of the search needs to be either the last 60 mins or the last 7 days. I am not sure on how to modify the time parameters on the search. I tried inserting the earliest/latest info into the PolicyTOK but had issues getting it to behave correctly &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;input type="dropdown" token="PolicyTOK"&amp;gt;
        &amp;lt;label&amp;gt;Details&amp;lt;/label&amp;gt;
        &amp;lt;choice value="untagged"&amp;gt;Untagged&amp;lt;/choice&amp;gt;
        &amp;lt;choice value="stopped"&amp;gt;Stopped&amp;lt;/choice&amp;gt;
        &amp;lt;choice value="terminated"&amp;gt;Terminated&amp;lt;/choice&amp;gt;
        &amp;lt;default&amp;gt;untagged&amp;lt;/default&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=xxx sourcetype=_json "message.Records{}.Sns.Message.policy.name"="$PolicyTOK$" | spath output=AccountId path=message.Records{}.Sns.Message.account_id | spath output=account path=message.Records{}.Sns.Message.account | spath output=region path=message.Records{}.Sns.Message.region | spath output=InstanceId path=message.Records{}.Sns.Message.resources{}.InstanceId |dedup AccountId | table account AccountId region InstanceId  | sort AccountId&amp;lt;/query&amp;gt;
        &amp;lt;earliest&amp;gt;-60m@m&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Mar 2018 16:46:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344106#M22388</guid>
      <dc:creator>a238574</dc:creator>
      <dc:date>2018-03-09T16:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Modify search time based on dropdown selection</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344107#M22389</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Try this - `&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 15:54:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344107#M22389</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2018-03-10T15:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Modify search time based on dropdown selection</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344108#M22390</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Try this - &lt;CODE&gt;| eval diff=round((now()-_time)/3600)|eval filter=case(("PolicyTOK"="untagged" OR&lt;BR /&gt;
"PolicyTOK"="stopped"),168,"PolicyTOK"="terminated",1) |where diff&amp;lt;=filter&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;What this does :&lt;BR /&gt;
The first eval calculates the difference in hours from current time (now()) till the time each event occured / was indexed (_time)&lt;BR /&gt;
Having got the difference in hours the second eval sets the filter (I am assuming , for example, untagged and stopped events need to filter events for the last 7 days) depending on the token selection to a limit value, 7*24=168 hours for 7 days and of course 1 hour for last 60 minutes.&lt;BR /&gt;
Now, the where will filter out unwanted events, so for example something that was indexed prior to 7 days will have a diff value greater than 168. Assuming that an user selection of untagged is made from the dropdown the where will eliminate all events where diff is greater than 168.&lt;/P&gt;

&lt;P&gt;You might need to tinker this around a bit to fit your requirements exactly.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Mar 2018 15:55:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344108#M22390</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2018-03-10T15:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Modify search time based on dropdown selection</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344109#M22391</link>
      <description>&lt;P&gt;@a238574, you can use dropdown's &lt;CODE&gt;&amp;lt;change&amp;gt;&lt;/CODE&gt; event handler to set additional time tokens as needed.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4527i8BDAEC8EFCD4DFF6/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
Following is a run anywhere dashboard example based on your question. PS: You have defined three static dropdown values and two time ranges to be selected. Please confirm time range to be applied for specific option selected. I have set first two options i.e. &lt;CODE&gt;untagged&lt;/CODE&gt; and &lt;CODE&gt;Stopped&lt;/CODE&gt; with &lt;CODE&gt;last 7 days&lt;/CODE&gt; time range and &lt;CODE&gt;Terminated&lt;/CODE&gt; with &lt;CODE&gt;last 60 minutes&lt;/CODE&gt; time range. Please correct as per your use case.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Drilldown Change Event Handler&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;&amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;input type="dropdown" token="PolicyTOK" searchWhenChanged="true"&amp;gt;
        &amp;lt;label&amp;gt;Details&amp;lt;/label&amp;gt;
        &amp;lt;choice value="untagged"&amp;gt;Untagged&amp;lt;/choice&amp;gt;
        &amp;lt;choice value="stopped"&amp;gt;Stopped&amp;lt;/choice&amp;gt;
        &amp;lt;choice value="terminated"&amp;gt;Terminated&amp;lt;/choice&amp;gt;
        &amp;lt;default&amp;gt;untagged&amp;lt;/default&amp;gt;
        &amp;lt;change&amp;gt;
          &amp;lt;condition value="untagged"&amp;gt;
            &amp;lt;set token="earliestTime"&amp;gt;-7d@d&amp;lt;/set&amp;gt;
            &amp;lt;set token="latestTime"&amp;gt;now&amp;lt;/set&amp;gt;
          &amp;lt;/condition&amp;gt;
          &amp;lt;condition value="stopped"&amp;gt;
            &amp;lt;set token="earliestTime"&amp;gt;-7d@d&amp;lt;/set&amp;gt;
            &amp;lt;set token="latestTime"&amp;gt;now&amp;lt;/set&amp;gt;
          &amp;lt;/condition&amp;gt;
          &amp;lt;condition value="terminated"&amp;gt;
            &amp;lt;set token="earliestTime"&amp;gt;-60m@m&amp;lt;/set&amp;gt;
            &amp;lt;set token="latestTime"&amp;gt;now&amp;lt;/set&amp;gt;
          &amp;lt;/condition&amp;gt;
        &amp;lt;/change&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Token Data (testing only) --&amp;gt; PolicyTOK: $PolicyTOK$ | earliestTime: $earliestTime$ | latestTime: $latestTime$&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval PolicyTOK="$PolicyTOK$" 
| addinfo
| fieldformat info_min_time=strftime(info_min_time,"%Y/%m/%d %H:%M:%S")
| fieldformat info_max_time=strftime(info_max_time,"%Y/%m/%d %H:%M:%S")&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;$earliestTime$&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;$latestTime$&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Mar 2018 18:24:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344109#M22391</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-03-10T18:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Modify search time based on dropdown selection</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344110#M22392</link>
      <description>&lt;P&gt;Simple and functional.... I know where I made my mistake....   I was adding the time parameters to the query using an incorrect syntax&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 11:08:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Modify-search-time-based-on-dropdown-selection/m-p/344110#M22392</guid>
      <dc:creator>a238574</dc:creator>
      <dc:date>2018-03-12T11:08:07Z</dc:date>
    </item>
  </channel>
</rss>

