<?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: Extract data for weekends. in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Extract-data-for-weekends/m-p/308048#M4073</link>
    <description>&lt;P&gt;Hi&lt;BR /&gt;
I'd use the date_wday field to filer week-end's events&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="history" source = "DetailedLogs" (date_wday=sunday OR date_wday=saturday)
| transaction source maxspan=72h
| timechart sum(duration) AS duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Duration is expressed in seconds, if you like you can express it using eval at the end of the search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval duration=tostring(duration,"duration")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
    <pubDate>Tue, 29 Aug 2017 12:13:09 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2017-08-29T12:13:09Z</dc:date>
    <item>
      <title>Extract data for weekends.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Extract-data-for-weekends/m-p/308047#M4072</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I need to calculate the amount of time for which a server was used in the weekends. For that I am using the following search string :&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;index="history" source = "DetailedLogs" | transaction source | convert ctime(_time) AS day_of_week timeformat="%A" | convert ctime(_time) AS day timeformat="%e" | eval weekendno = case(day&amp;gt;=1 AND day &amp;lt;=7 AND (day_of_week=="Saturday" OR day_of_week=="Sunday"),"Weekend 1", day&amp;gt;7 AND day&amp;lt;=14 AND (day_of_week=="Saturday" OR day_of_week=="Sunday"),"Weekend 2",day&amp;gt;14 AND day &amp;lt;=21 AND (day_of_week=="Saturday" OR day_of_week=="Sunday"),"Weekend 3",day&amp;gt;21 AND (day_of_week=="Saturday" OR day_of_week=="Sunday"),"Weekend 4") | chart count(duration) by weekendno&lt;/STRONG&gt;&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;Firstly, after executing the search string, I am getting results of usage of the server on weekdays as well. So, clearly there's something wrong with it. Can someone point out the mistake or is there any better approach to achieve the same result?&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Also, I want to count the total duration of usage, for which I should use the sum() function but it is giving me an error. &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;What is the default unit of the "duration" field? Is it seconds or hours?&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;PFA attached the screenshots. One of the event fetched has a timestamp "08-29-2017:11:41:42" which is a Tuesday.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/209705-splunk-issue.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/209708-splunk-issue2.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:33:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Extract-data-for-weekends/m-p/308047#M4072</guid>
      <dc:creator>mmukherjee</dc:creator>
      <dc:date>2020-09-29T15:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Extract data for weekends.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Extract-data-for-weekends/m-p/308048#M4073</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
I'd use the date_wday field to filer week-end's events&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="history" source = "DetailedLogs" (date_wday=sunday OR date_wday=saturday)
| transaction source maxspan=72h
| timechart sum(duration) AS duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Duration is expressed in seconds, if you like you can express it using eval at the end of the search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval duration=tostring(duration,"duration")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2017 12:13:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Extract-data-for-weekends/m-p/308048#M4073</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-08-29T12:13:09Z</dc:date>
    </item>
  </channel>
</rss>

