<?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: Counting the Total Number of Days for all Time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150112#M42048</link>
    <description>&lt;P&gt;If I wanted data from last May, I would want Splunk to tell me that there were 4 Mondays , 4 Tuesdays, 4 Wednesdays, 4 Thursdays, 5 Fridays, 5 Saturdays, and 5 Sundays in that month. Does that clear things up?&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jun 2015 16:52:40 GMT</pubDate>
    <dc:creator>TJemisonIpacc</dc:creator>
    <dc:date>2015-06-12T16:52:40Z</dc:date>
    <item>
      <title>Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150102#M42038</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;

&lt;P&gt;I'm trying to create a search that averages a sum of payments and counts the total number of days for all time(starts at the first event and keeps going until the last). The problem is the second part. My current search only returns  how many events took place on each day, which gives me huge numbers. I'm only looking for the total number of each day of the week over a time period.&lt;/P&gt;

&lt;P&gt;This is what I have right now:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | rex field=_raw "(?P&amp;lt;paymentAmount&amp;gt;\w+) date_wday: (?P&amp;lt;time&amp;gt;\d+)ms" | eval date_wday=strftime(_time,"%w-%A")| stats sum(paymentAmount), count(date_wday)  by date_wday| eval date_wday=replace(date_wday,"(\d+-)(\w+)","\2")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:18:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150102#M42038</guid>
      <dc:creator>TJemisonIpacc</dc:creator>
      <dc:date>2015-06-12T14:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150103#M42039</link>
      <description>&lt;P&gt;First of all: beware the built-in &lt;CODE&gt;date_wday&lt;/CODE&gt; (I see you are making your own, which is VERY GOOD).  In most Splunk datasets the &lt;CODE&gt;date_*&lt;/CODE&gt; fields almost always exist and because of this you may not notice that sometimes they don’t!  Most people naturally assume these fields are default fields (like &lt;CODE&gt;_time&lt;/CODE&gt;) that are always there but these fields are actually pre-TZ-normalization side-effects from Splunk’s timestamping process. If Splunk does not (have to) parse an event to set its timestamp then the &lt;CODE&gt;date_*&lt;/CODE&gt; fields will not exist. Windows event logs, for example, now come in via a modular input that is designed to use the pre-parsed time as it comes from the Windows event log APIs, obviating the need for Splunk to do any timestamp parsing, therefore the &lt;CODE&gt;date_*&lt;/CODE&gt; fields are not created, do not exist, and are unavailable for our use.  Did you catch that they are &lt;EM&gt;pre-TZ-normalization&lt;/EM&gt;?  That means that if you modified the TZ, then these fields DID NOT GET MODIFIED and ARE NOT CORRECT.&lt;/P&gt;

&lt;P&gt;Anyway, your search is pretty much OK if you are trying to group all Fridays together and all Saturdays together, etc:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; base search | rex "(?&amp;lt;paymentAmount&amp;gt;\w+) date_wday: (?&amp;lt;time&amp;gt;\d+)ms" | eval date_wday=strftime(_time,"%A") | stats sum(paymentAmount), count BY date_wday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But, another way to read your post is that you'd like a summary for each day, which is different:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; base search | rex "(?&amp;lt;paymentAmount&amp;gt;\w+) date_wday: (?&amp;lt;time&amp;gt;\d+)ms" | bucket _time span=1d | stats sum(paymentAmount), count BY _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a reason that you are capturing field &lt;CODE&gt;time&lt;/CODE&gt; but not using it?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:39:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150103#M42039</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-12T14:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150104#M42040</link>
      <description>&lt;P&gt;Hello! As woodcock is saying, you are not using the &lt;STRONG&gt;time&lt;/STRONG&gt; you have extracted. Also, i think you don't need the &lt;STRONG&gt;by&lt;/STRONG&gt; clause herere. I propose that you opdate your query like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; base search | rex field=_raw "(?P&amp;lt;paymentAmount&amp;gt;\w+) date_wday: (?P&amp;lt;time&amp;gt;\d+)ms" | eval date_wday=strftime(time,"%w-%A")| stats sum(paymentAmount), count(date_wday)  | eval date_wday=replace(date_wday,"(\d+-)(\w+)","\2")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 15:00:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150104#M42040</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-06-12T15:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150105#M42041</link>
      <description>&lt;P&gt;Yes, I'm trying to group all Fridays, Saturdays, Mondays, etc. together. I still think the search is returning the wrong results, however. Right now it is telling me that there are only two Sundays, which isn't true. The events go back to January, so there should be roughly 25 or so Sundays. Another issue is that I actually overlooked the fact that there was already a date_wday field for the reported evetns. I'm not sure if it would cause some kind of overlap issue, so I changed it to this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; base search | rex "(?&amp;lt;paymentAmount&amp;gt;\w+) days: (?&amp;lt;time&amp;gt;\d+)ms" | eval days=strftime(_time,"%A") | stats sum(paymentAmount), count BY days
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;No, there isn't a reason I captured the time field. Should I put something else in its place? &lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 15:09:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150105#M42041</guid>
      <dc:creator>TJemisonIpacc</dc:creator>
      <dc:date>2015-06-12T15:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150106#M42042</link>
      <description>&lt;P&gt;I tried this out using the code you posted and the code I posted in reponse to woodcock's comment. The search returned zero as the value for count. Is there a reason you wanted me to remove the by clause? I'm fairly new to Splunk, but I think I'll need it if I want the total number of days for each day of the week.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 15:20:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150106#M42042</guid>
      <dc:creator>TJemisonIpacc</dc:creator>
      <dc:date>2015-06-12T15:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150107#M42043</link>
      <description>&lt;P&gt;It is counting ONLY those Sundays which have events so the search is correct.  If you'd like to count all Sundays, then (first say so) and then do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; base search | rex "(?&amp;lt;paymentAmount&amp;gt;\w+) date_wday: (?&amp;lt;time&amp;gt;\d+)ms" | timechart span=1d sum(paymentAmount) AS paymentAmount count | eval date_wday=strftime(_time,"%A") | stats sum(paymentAmount), sum(count) AS count BY date_wday
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The difference is that &lt;CODE&gt;timechart&lt;/CODE&gt; creates &lt;CODE&gt;0&lt;/CODE&gt;-value rows but &lt;CODE&gt;stats&lt;/CODE&gt; does not.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 15:52:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150107#M42043</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-12T15:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150108#M42044</link>
      <description>&lt;P&gt;Sorry to keep bothering you, but could you give an example of how I would tell Splunk to count all Sundays (the step I need to do before using the code you posted)?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 16:06:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150108#M42044</guid>
      <dc:creator>TJemisonIpacc</dc:creator>
      <dc:date>2015-06-12T16:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150109#M42045</link>
      <description>&lt;P&gt;The code that I just posted is the complete answer and already does that; the explanation below it was bonus.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 16:08:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150109#M42045</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-06-12T16:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150110#M42046</link>
      <description>&lt;P&gt;It worked. Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 16:12:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150110#M42046</guid>
      <dc:creator>TJemisonIpacc</dc:creator>
      <dc:date>2015-06-12T16:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150111#M42047</link>
      <description>&lt;P&gt;Sorry, but i don't understand when you say, you want  the total number of days for each day of the week and that is why i'v said you don't need the &lt;CODE&gt;by date_wday&lt;/CODE&gt; clause here. I'm really sorry.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 16:45:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150111#M42047</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-06-12T16:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150112#M42048</link>
      <description>&lt;P&gt;If I wanted data from last May, I would want Splunk to tell me that there were 4 Mondays , 4 Tuesdays, 4 Wednesdays, 4 Thursdays, 5 Fridays, 5 Saturdays, and 5 Sundays in that month. Does that clear things up?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 16:52:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150112#M42048</guid>
      <dc:creator>TJemisonIpacc</dc:creator>
      <dc:date>2015-06-12T16:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Counting the Total Number of Days for all Time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150113#M42049</link>
      <description>&lt;P&gt;wo wo wo. Thanks. That is verry clear now. Sorry&lt;/P&gt;

&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 17:01:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Counting-the-Total-Number-of-Days-for-all-Time/m-p/150113#M42049</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-06-12T17:01:10Z</dc:date>
    </item>
  </channel>
</rss>

