<?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 can I split splunk query into time ranges? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612103#M212823</link>
    <description>&lt;P&gt;Use eval to break the results into 2-week periods then have stats group the results by period.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval period=if(_time&amp;gt;=relative_time(now(), "-2w"), "LATEST 2 WEEKS", "PREVIOUS 2 WEEKS")
| stats dc(objects) as OBJ by errorMessage, period&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 06 Sep 2022 13:18:24 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2022-09-06T13:18:24Z</dc:date>
    <item>
      <title>How can I split Splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/611870#M212727</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;If I am searching through the past 4 weeks in one query, how can I break this data into two columns, one for previous 2 weeks, and one for latest 2 weeks, then sort by Latest 2 weeks?&lt;/P&gt;
&lt;P&gt;In general, im using stats to display the amount of objects affected by errors occurring&amp;nbsp; in a 4 week period but would like to see them displayed in two 2 week periods, sorted by the amount in the latest 2 weeks.&lt;/P&gt;
&lt;P&gt;| stats dc(objects) as OBJ by errorMessage&lt;/P&gt;
&lt;P&gt;| span -OBJ&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;CURRENT OUTPUT&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;ERROR MESSAGE&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;OBJ&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;message 1&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;1792&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;message 2&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;1210&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;message 3&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;957&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;DESIRED OUTPUT&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;ERROR MESSAGE&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;LATEST 2 WEEKS&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;PREVIOUS 2 WEEKS&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;message 1&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;967&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;825&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;message 2&lt;/TD&gt;
&lt;TD height="25px"&gt;872&lt;/TD&gt;
&lt;TD height="25px"&gt;666&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;message 3&lt;/TD&gt;
&lt;TD height="25px"&gt;103&lt;/TD&gt;
&lt;TD height="25px"&gt;854&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks all,&lt;/P&gt;
&lt;P&gt;Corey&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 14:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/611870#M212727</guid>
      <dc:creator>coreytoast</dc:creator>
      <dc:date>2022-09-06T14:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/611872#M212729</link>
      <description>&lt;P&gt;Basic way to split by _time is to use either&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... search ...
| timechart span=2w&lt;/LI-CODE&gt;&lt;P&gt;or to use an aggregation command splitting by time where you define the window, like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... search ...
| bin _time span=2w
| stats .... by _time&lt;/LI-CODE&gt;&lt;P&gt;depending on what you want your output to be will dictate what fits your use case&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2022 23:54:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/611872#M212729</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-09-04T23:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/611873#M212730</link>
      <description>&lt;P&gt;Please tell us more about the use case?&amp;nbsp; What kind of data?&amp;nbsp; What should the output look like?&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2022 23:55:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/611873#M212730</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-09-04T23:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612064#M212817</link>
      <description>&lt;P&gt;updated question&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 09:58:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612064#M212817</guid>
      <dc:creator>coreytoast</dc:creator>
      <dc:date>2022-09-06T09:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612065#M212818</link>
      <description>&lt;P&gt;I have updated my question to give more context&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 10:05:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612065#M212818</guid>
      <dc:creator>coreytoast</dc:creator>
      <dc:date>2022-09-06T10:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612103#M212823</link>
      <description>&lt;P&gt;Use eval to break the results into 2-week periods then have stats group the results by period.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval period=if(_time&amp;gt;=relative_time(now(), "-2w"), "LATEST 2 WEEKS", "PREVIOUS 2 WEEKS")
| stats dc(objects) as OBJ by errorMessage, period&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 06 Sep 2022 13:18:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612103#M212823</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-09-06T13:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612108#M212824</link>
      <description>&lt;P&gt;You can also look into the &lt;STRONG&gt;| timewrap&lt;/STRONG&gt; command.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 13:57:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612108#M212824</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-09-06T13:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split Splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612174#M212833</link>
      <description>&lt;P&gt;Use something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;...
| bin _time span=2w@w aligntime=@w
| eval t=if(_time &amp;lt; relative_time(now(), "-2w@w"), "Previous", "Latest")
| chart dc(objects) as OBJ over errorMessage by t
| sort - Latest&lt;/LI-CODE&gt;&lt;P&gt;bin will segregate time into two week sections. t= will then categorise which period the event fits into, then chart will do your tabling.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 23:33:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612174#M212833</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-09-06T23:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split Splunk query into time ranges?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612897#M213059</link>
      <description>&lt;P&gt;This worked perfectly, thank you so much&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 14:02:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-Splunk-query-into-time-ranges/m-p/612897#M213059</guid>
      <dc:creator>coreytoast</dc:creator>
      <dc:date>2022-09-13T14:02:18Z</dc:date>
    </item>
  </channel>
</rss>

