<?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: Average event count using only business days (M-F) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634394#M220389</link>
    <description>&lt;P&gt;When I put the exact code into search field, I get a table with dates (which are M-F dates, which is good) on the left under "_time" and an "Avg" column on the right that is blank.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2023 11:58:17 GMT</pubDate>
    <dc:creator>JoshSaunders</dc:creator>
    <dc:date>2023-03-14T11:58:17Z</dc:date>
    <item>
      <title>Average event count using only business days (M-F)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634379#M220378</link>
      <description>&lt;P&gt;I have a specific event that I'm looking to do an average count for the past 5 business days.&lt;/P&gt;
&lt;P&gt;Right now, I'm able to get the weekly average with the following search, but want to restrict that count to only business days, so that the average is more reflective of a normal workday. Including weekends significantly lowers the running average, so the information isn't helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;source="wineventlog:application" EventCode=9999 | timechart span=7d count as Avg | eval Avg=round(Avg/7,2)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance for any assistance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 16:18:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634379#M220378</guid>
      <dc:creator>JoshSaunders</dc:creator>
      <dc:date>2023-03-15T16:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634383#M220381</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254408"&gt;@JoshSaunders&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you want to exclude only Saturday and Sunday, you can add this filter to the main search and you easily solve your need:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="wineventlog:application" EventCode=9999 NOT (date_wday="saturday" OR date_wday="sunday")
| bin span=1d _time 
| stats avg(count) AS Avg BY _time
| eval Avg=round(Avg,2)&lt;/LI-CODE&gt;&lt;P&gt;if you haven't the date_wday field, you have to extract adding the following eval expression&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="wineventlog:application" EventCode=9999 
| eval date_wday=strftime(_time,"%A")
| search NOT (date_wday="Saturday" OR date_wday="Sunday")
| bin span=1d _time 
| stats avg(count) AS Avg BY _time
| eval Avg=round(Avg,2)&lt;/LI-CODE&gt;&lt;P&gt;if insteads you want to consider also holydays, you have to create a lookup containing the holidays and filter your search for this lookup.&lt;/P&gt;&lt;P&gt;In other words, you create a lookup containing all the holydays&amp;nbsp;and the weekends in a column called e.g. holyday, then you have to run something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="wineventlog:application" EventCode=9999 
| eval date=strftime(_time, "%Y-%m-%d")
| search NOT [ | inputlookup holydays.csv | rename holyday AS date | fields date ]
| bin span=1d _time 
| stats avg(count) AS Avg BY _time
| eval Avg=round(Avg,2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Put attention that the date format in the lookup will be the same of the date field (%Y-%m-%d" or another) .&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 11:09:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634383#M220381</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-14T11:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634389#M220386</link>
      <description>&lt;P&gt;Thank you for the reply. When I use the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="wineventlog:application" EventCode=9999 
| eval date_wday=strftime(_time,"%A")
| search NOT (date_wday="Saturday" OR date_wday="Sunday")
| bin span=1d _time 
| stats avg(count) AS Avg BY _time
| eval Avg=round(Avg,2)&lt;/LI-CODE&gt;&lt;P&gt;It displays a "0" with an arrow to a smaller zero instead of the average number per day.&lt;/P&gt;&lt;P&gt;Doing a search adding each part, it does appear to remove Sat and Sun data, though.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 11:35:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634389#M220386</guid>
      <dc:creator>JoshSaunders</dc:creator>
      <dc:date>2023-03-14T11:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634392#M220387</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254408"&gt;@JoshSaunders&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;which visualization are you using?&lt;/P&gt;&lt;P&gt;check in a table if results are correct, then you can define visualization.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 11:55:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634392#M220387</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-14T11:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634393#M220388</link>
      <description>&lt;P&gt;I should've mentioned that this is for a &amp;lt;single&amp;gt; dashboard value. So I have it as follows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;single&amp;gt;
 &amp;lt;title&amp;gt;Daily Average&amp;lt;/title&amp;gt;
 &amp;lt;search&amp;gt;
  &amp;lt;query&amp;gt;
   source="wineventlog:application" EventCode=9999
   | eval date_wday=strftime(_time,"%A")
   | search NOT (date_wday="saturday" OR date_wday="sunday")
   | bin span=1d _time
   | stats avg(count) AS Avg BY _time
   | eval Avg=round(Avg,2)
  &amp;lt;/query&amp;gt;
 &amp;lt;/search&amp;gt;
&amp;lt;/single&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Mar 2023 11:56:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634393#M220388</guid>
      <dc:creator>JoshSaunders</dc:creator>
      <dc:date>2023-03-14T11:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634394#M220389</link>
      <description>&lt;P&gt;When I put the exact code into search field, I get a table with dates (which are M-F dates, which is good) on the left under "_time" and an "Avg" column on the right that is blank.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 11:58:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634394#M220389</guid>
      <dc:creator>JoshSaunders</dc:creator>
      <dc:date>2023-03-14T11:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634395#M220390</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254408"&gt;@JoshSaunders&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;in this case results shuld be only two values: the acxtual value and the previous one, I forgot this requisite, so please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="wineventlog:application" EventCode=9999 earliest=-14d latest=now
| eval date_wday=strftime(_time,"%A")
| search NOT (date_wday="saturday" OR date_wday="sunday")
| bin span=7d _time
| stats avg(count) AS Avg BY _time
| eval Avg=round(Avg,2)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 12:04:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634395#M220390</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-14T12:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634401#M220392</link>
      <description>&lt;P&gt;I was able to get it to work with this (I THINK):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="wineventlog:application" EventCode=9999 earliest=-14d latest=now
| eval date_wday=strftime(_time,"%A")
| search NOT (date_wday="saturday" OR date_wday="sunday")
| bin span=7d _time
| stats avg(count) AS Avg
| eval Avg=round(Avg/14,2)&lt;/LI-CODE&gt;&lt;P&gt;That search displays a number that looks to be about the average amount I expected per day.&lt;/P&gt;&lt;P&gt;Thank you for all your help!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 12:37:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634401#M220392</guid>
      <dc:creator>JoshSaunders</dc:creator>
      <dc:date>2023-03-14T12:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634409#M220395</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254408"&gt;@JoshSaunders&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if one answer solves your need, please accept one answer for the other people of Community or tell me how I can help you.&lt;/P&gt;&lt;P&gt;Ciao and happy splunking&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 13:15:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634409#M220395</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-14T13:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634427#M220411</link>
      <description>&lt;P&gt;Don't rely on the date_* fields unless you are absolutely sure they will be in the events and they will have proper values. They might not be generated if the original event had no timestamp in them. And they might be reflecting the event's timezone instead of your own (remember that even if all your sources and you are in the same timezone, the source might be misconfigured or might be reporting time in a predefined timezone).&lt;/P&gt;&lt;P&gt;To be honest, I have no idea what these are good for.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 15:16:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634427#M220411</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-03-14T15:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Average event count using only business days (M-F)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634433#M220412</link>
      <description>&lt;P&gt;We have Horizon VDI VMs that people login to with zeroclients. I have a scheduled task on the golden image set to run a script on login to create Event ID 9999 that logs the username, zeroclient name, zeroclient IP, VM name, and VM IP.&amp;nbsp; That allows us to see what zeroclient each user is using to login to what VM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since we already had that event, we also wanted to be able to see a running daily average number of VDI logins that occur to determine how many VMs are in use per day in the average workday. So as VDI usage increases, we can make sure we have enough resources.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 16:15:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Average-event-count-using-only-business-days-M-F/m-p/634433#M220412</guid>
      <dc:creator>JoshSaunders</dc:creator>
      <dc:date>2023-03-14T16:15:27Z</dc:date>
    </item>
  </channel>
</rss>

