<?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: Compare day to same day for N weeks in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53747#M13076</link>
    <description>&lt;P&gt;Thanks that worked perfectly&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jun 2013 20:07:27 GMT</pubDate>
    <dc:creator>michaudel</dc:creator>
    <dc:date>2013-06-04T20:07:27Z</dc:date>
    <item>
      <title>How to compare day to same day for N weeks?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53744#M13073</link>
      <description>&lt;P&gt;I got a question where someone is looking for the hits to a page, but only on Fridays between 6PM and 2 AM the following Saturday. I looked around a bit for a good way to do this and hadn't come up with anything so I thought I would ask.&lt;/P&gt;
&lt;P&gt;The challenge here is the fact that we only care about Fridays during a certain time period.&lt;/P&gt;
&lt;P&gt;I started with this:&lt;BR /&gt;earliest=@w5+18h latest=@w6+2h index=...&lt;/P&gt;
&lt;P&gt;but the problem is this only gets me last Friday. I would like to pull every friday for the last "n" weeks.&lt;/P&gt;
&lt;P&gt;So i wrote this and it works pretty well, but what I don't like is that splunk still searches every day, only to throw out all but a few days. Thought i would see if anyone had a better way to do this, thanks, Ethan&lt;/P&gt;
&lt;P&gt;index=... ... | eval sdate = strftime(_time,"%a %d %B %Y - %H") | eval day = strftime(_time,"%a") | eval hour = strftime(_time,"%H") |search hour &amp;gt;= "18" OR hour = "00" OR hour = "01" AND day = "Fri" |stats count(hits) as HIT by sdate&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 21:05:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53744#M13073</guid>
      <dc:creator>michaudel</dc:creator>
      <dc:date>2023-08-10T21:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Compare day to same day for N weeks</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53745#M13074</link>
      <description>&lt;P&gt;There is a much easier way to do this. It will not work for all types of data (the only example of which, AFAIK, are WinEventLogs). So most logfile types will work. &lt;/P&gt;

&lt;P&gt;Splunk will automatically (for each event) create fields called &lt;CODE&gt;date_hour&lt;/CODE&gt;, &lt;CODE&gt;date_wday&lt;/CODE&gt;, &lt;CODE&gt;date_minute&lt;/CODE&gt; etc, which can be used for this purpose, so;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=blah (date_wday=friday date_hour&amp;gt;18) OR (date_wday=saturday date_hour&amp;lt;2) | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;would find those events. &lt;/P&gt;

&lt;P&gt;NB. These &lt;CODE&gt;date_*&lt;/CODE&gt; fields will be created from the timestamp inside the event WITHOUT compensating for TZ.&lt;/P&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2013 20:09:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53745#M13074</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-06-03T20:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Compare day to same day for N weeks</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53746#M13075</link>
      <description>&lt;P&gt;Once you have your data using a base search like Kristian's above you can use something like this ( &lt;A href="http://splunk-base.splunk.com/answers/59045/how-do-i-make-a-multi-dimension-timechart"&gt;http://splunk-base.splunk.com/answers/59045/how-do-i-make-a-multi-dimension-timechart&lt;/A&gt; ) to chart your comparisons.&lt;/P&gt;

&lt;P&gt;Here is a good blog post also explaining how to display overlapping time frames ( &lt;A href="http://blogs.splunk.com/2012/02/19/compare-two-time-ranges-in-one-report"&gt;http://blogs.splunk.com/2012/02/19/compare-two-time-ranges-in-one-report&lt;/A&gt; ).&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2013 06:20:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53746#M13075</guid>
      <dc:creator>Lucas_K</dc:creator>
      <dc:date>2013-06-04T06:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Compare day to same day for N weeks</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53747#M13076</link>
      <description>&lt;P&gt;Thanks that worked perfectly&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2013 20:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53747#M13076</guid>
      <dc:creator>michaudel</dc:creator>
      <dc:date>2013-06-04T20:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Compare day to same day for N weeks</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53748#M13077</link>
      <description>&lt;P&gt;Thanks I checked it out, got to where i need from above, then started to work to make the overlapping time frames... thanks again&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2013 20:08:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/53748#M13077</guid>
      <dc:creator>michaudel</dc:creator>
      <dc:date>2013-06-04T20:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Compare day to same day for N weeks</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/653953#M225998</link>
      <description>&lt;P&gt;Thanks for this.&amp;nbsp; Sometimes we overthink solutions and fail to see the easiest one is right in front of us.&amp;nbsp; I spent all morning trying timewrap and a variety of datetime math solutions because all I wanted to do was compare the 11am hour of bytes per host every day of the week to troubleshoot a problem.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 14:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-day-to-same-day-for-N-weeks/m-p/653953#M225998</guid>
      <dc:creator>sjbriggs</dc:creator>
      <dc:date>2023-08-10T14:57:33Z</dc:date>
    </item>
  </channel>
</rss>

