<?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 use two time ranges in one search in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288813#M18275</link>
    <description>&lt;P&gt;@anuremanan88, I think you need to use sub-searches for two different EventType with specific timerange using earliest and latest. You can use append, join, multisearch or union command based on your use case(search type). Refer to the following documentation for deciding your option/s:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Multisearch"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Multisearch&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Union"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Union&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2017 06:35:39 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-10-06T06:35:39Z</dc:date>
    <item>
      <title>How to use two time ranges in one search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288812#M18274</link>
      <description>&lt;P&gt;Hi I am trying to search for two event types each in different time range. Here i am using time token. The eventtypes are "Password Change" and "Login". When i apply search for last 4 hrs, my query should search "password change" event for last 4 hrs and "login" event for last 8hrs. Similarly when i change the time filter my query should change accordingly.&lt;/P&gt;

&lt;P&gt;index=new (EventType="Password Change" earliest=$token.earliest$ latest=$token.earliest$) OR (EventType="Login" earliest=$token.earliest$-4h latest=$token.earliest$) | remaining query&lt;/P&gt;

&lt;P&gt;Anyone can help me in this?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 20:41:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288812#M18274</guid>
      <dc:creator>anuremanan88</dc:creator>
      <dc:date>2017-10-05T20:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use two time ranges in one search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288813#M18275</link>
      <description>&lt;P&gt;@anuremanan88, I think you need to use sub-searches for two different EventType with specific timerange using earliest and latest. You can use append, join, multisearch or union command based on your use case(search type). Refer to the following documentation for deciding your option/s:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Multisearch"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Multisearch&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Union"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Union&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 06:35:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288813#M18275</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-06T06:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use two time ranges in one search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288814#M18276</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=new (EventType="Password Change" earliest=$earliest.earliest$) OR (EventType="Login" earliest=$earliest.earliest$-4h latest=$earliest.earliest$)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to see the token for earliest, use &lt;CODE&gt;&amp;lt;form script="showtokens.js"&amp;gt;&lt;/CODE&gt; at the top of the source code. when i was testing it, my earliest was &lt;CODE&gt;$earliest.earliest$&lt;/CODE&gt;, not &lt;CODE&gt;$token.earliest$&lt;/CODE&gt;. You don't need to put a latest in your first search, if you're looking for the last four hours. if you do want a latest, perhaps use &lt;CODE&gt;latest=$earliest.earliest$+4h&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="showtokens.js"&amp;gt;
  &amp;lt;label&amp;gt;testdash&amp;lt;/label&amp;gt;
  &amp;lt;fieldset submitButton="true"&amp;gt;
    &amp;lt;input type="time" token="earliest"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;
        &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
        &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
      &amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index=myindex (sourcetype=mysource1 earliest=$earliest.earliest$) OR (sourcetype=mysource2 earliest=$earliest.earliest$-4h latest=$earliest.earliest$)|stats earliest(_time) latest(_time) by sourcetype&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-4h@h&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;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 12:13:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288814#M18276</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-10-06T12:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use two time ranges in one search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288815#M18277</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;

&lt;P&gt;Thank You for your inputs. This worked when i use relative time as input. However when i give Date and time range as input. i am getting the below error&lt;/P&gt;

&lt;P&gt;Invalid value "1506657600-4h" for time term 'earliest'&lt;/P&gt;

&lt;P&gt;Hoe to fix this?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 13:40:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288815#M18277</guid>
      <dc:creator>anuremanan88</dc:creator>
      <dc:date>2017-10-06T13:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to use two time ranges in one search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288816#M18278</link>
      <description>&lt;P&gt;@ anuremanan88, Try &lt;CODE&gt;$earliest.earliest$-14400&lt;/CODE&gt; instead of &lt;CODE&gt;$earliest.earliest$-4h&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 13:45:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288816#M18278</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-10-06T13:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to use two time ranges in one search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288817#M18279</link>
      <description>&lt;P&gt;It gives the same result " Invalid value "1506657600-14400" for time term 'earliest' "&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 14:04:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-use-two-time-ranges-in-one-search/m-p/288817#M18279</guid>
      <dc:creator>anuremanan88</dc:creator>
      <dc:date>2017-10-06T14:04:03Z</dc:date>
    </item>
  </channel>
</rss>

