<?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: Creating predefined timerange for service period in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223222#M13864</link>
    <description>&lt;P&gt;When you use it in the dropdown value, it will not evaluate as a search... It will just remain as a string. Where ever you run the query that is where you will append the string $selectedTimeWindow$&lt;/P&gt;</description>
    <pubDate>Sun, 08 Jan 2017 12:39:07 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-01-08T12:39:07Z</dc:date>
    <item>
      <title>Creating predefined timerange for service period</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223217#M13859</link>
      <description>&lt;P&gt;Is it possible to define named (relative) time ranges (with use of macros or other teqniques) for &lt;EM&gt;service hours&lt;/EM&gt; (07:00-18:00 monday-friday) and &lt;EM&gt;calculation period&lt;/EM&gt; (first day in a month to last in a month) so I can easily change between current and previous calculation periods in dashboards/panels/stat charts?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Scenario 1&lt;/STRONG&gt;&lt;BR /&gt;
Default should be to select current calculation period, which is from first day in this month (01.01.2016) to current date 07.01.2016, and only filter service hours.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Scenario 2&lt;/STRONG&gt;&lt;BR /&gt;
Then I can just pick previous month and year, let say December 2016 and filters on service hours for that month and year.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Disclamer!&lt;/STRONG&gt;&lt;BR /&gt;
Im quite new to Splunk, so please excuse any missusing of commom terms and techniques, and feel free to correct me!&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2017 08:56:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223217#M13859</guid>
      <dc:creator>ismarslomic</dc:creator>
      <dc:date>2017-01-07T08:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating predefined timerange for service period</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223218#M13860</link>
      <description>&lt;P&gt;Following should be added to your base search &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt; AND (date_wday="monday" OR date_wday="tuesday" OR date_wday="wednesday" OR date_wday="thursday" OR date_wday="friday") AND (date_hour&amp;gt;=7 AND date_hour&amp;lt;=18)  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also do the following, however, for search query performance inclusion is better than exclusion&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt; AND (date_wday!="saturday" AND date_wday!="sunday") AND (date_hour&amp;gt;=7 AND date_hour&amp;lt;=18) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Since this is added to your base search you can save the same as &lt;STRONG&gt;eventtype&lt;/STRONG&gt; like &amp;lt;your_index_sourcetype&amp;amp;gt_working_hour. You can similarly create a non_working_hour eventtype with reverse search filter.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:19:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223218#M13860</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T12:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating predefined timerange for service period</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223219#M13861</link>
      <description>&lt;P&gt;Thanks, @niketnilay!&lt;BR /&gt;
But I will reuse exactly this time range filter in different search combinations. Would it be possible to extend the "Presets" list of Time range dropdown list so I can just apply this filter on different search combinations?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2017 09:14:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223219#M13861</guid>
      <dc:creator>ismarslomic</dc:creator>
      <dc:date>2017-01-08T09:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating predefined timerange for service period</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223220#M13862</link>
      <description>&lt;P&gt;Yes You can define a Dropdown with two static options or Labels i.e. Businees Hours and Non-Business Hours and Values will be the two queries as string. You can finally append to searches.&lt;/P&gt;

&lt;P&gt;If Drop Down name is selectedTimeWindow then your query will change to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;Your Base Search&amp;gt; $selectedTimeWindow$ | 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also instead of Eventtype you can define macros with the part of search query above and append to your own base search where ever required (also via Dropdown).&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2017 12:34:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223220#M13862</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-01-08T12:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating predefined timerange for service period</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223221#M13863</link>
      <description>&lt;P&gt;Important information about date_* (default datetime fields) is that only events which contains timestamp, generated from their systems, will get these default fields. See more at &lt;A href="https://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/Usedefaultfields"&gt;https://docs.splunk.com/Documentation/Splunk/6.5.1/Knowledge/Usedefaultfields&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2017 12:36:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223221#M13863</guid>
      <dc:creator>ismarslomic</dc:creator>
      <dc:date>2017-01-08T12:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating predefined timerange for service period</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223222#M13864</link>
      <description>&lt;P&gt;When you use it in the dropdown value, it will not evaluate as a search... It will just remain as a string. Where ever you run the query that is where you will append the string $selectedTimeWindow$&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2017 12:39:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223222#M13864</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-01-08T12:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating predefined timerange for service period</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223223#M13865</link>
      <description>&lt;P&gt;Following is what your Dropdown may look like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;fieldset submitButton="false" autoRun="true"&amp;gt;
    &amp;lt;input type="dropdown" token="selTimeWindow" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Select Time Window&amp;lt;/label&amp;gt;
      &amp;lt;choice value="(date_wday=&amp;amp;quot;monday&amp;amp;quot; OR date_wday=&amp;amp;quot;tuesday&amp;amp;quot; OR date_wday=&amp;amp;quot;wednesday&amp;amp;quot; OR date_wday=&amp;amp;quot;thursday&amp;amp;quot; OR date_wday=&amp;amp;quot;friday&amp;amp;quot;) AND (date_hour&amp;amp;gt;=7 AND date_hour&amp;amp;lt;=18)"&amp;gt;Weekday Business Hours&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="(date_wday=&amp;amp;quot;saturday&amp;amp;quot; OR date_wday=&amp;amp;quot;sunday&amp;amp;quot;) AND (date_hour&amp;amp;gt;=7 AND date_hour&amp;amp;lt;=18)"&amp;gt;Weekend Business Hours&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="(date_wday=&amp;amp;quot;monday&amp;amp;quot; OR date_wday=&amp;amp;quot;tuesday&amp;amp;quot; OR date_wday=&amp;amp;quot;wednesday&amp;amp;quot; OR date_wday=&amp;amp;quot;thursday&amp;amp;quot; OR date_wday=&amp;amp;quot;friday&amp;amp;quot;) AND (date_hour&amp;amp;lt;7 AND date_hour&amp;amp;gt;18)"&amp;gt;Weekday Non Business Hours&amp;lt;/choice&amp;gt;
      &amp;lt;choice value="(date_wday=&amp;amp;quot;saturday&amp;amp;quot; OR date_wday=&amp;amp;quot;sunday&amp;amp;quot;) AND  (date_hour&amp;amp;lt;7 AND date_hour&amp;amp;gt;18)"&amp;gt;Weekend Non Business Hours&amp;lt;/choice&amp;gt;
      &amp;lt;default&amp;gt;(date_wday="monday" OR date_wday="tuesday" OR date_wday="wednesday" OR date_wday="thursday" OR date_wday="friday") AND (date_hour&amp;amp;gt;=7 AND date_hour&amp;amp;lt;=18)&amp;lt;/default&amp;gt;
      &amp;lt;initialValue&amp;gt;(date_wday="monday" OR date_wday="tuesday" OR date_wday="wednesday" OR date_wday="thursday" OR date_wday="friday") AND (date_hour&amp;amp;gt;=7 AND date_hour&amp;amp;lt;=18)&amp;lt;/initialValue&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can then feed the value selected in Drop Down to your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;index=_internal sourcetype=splunkd AND $selTimeWindow$ 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;| stats count by group&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2017 12:50:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Creating-predefined-timerange-for-service-period/m-p/223223#M13865</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-01-08T12:50:09Z</dc:date>
    </item>
  </channel>
</rss>

