<?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 How to have Splunk search to include only events outside regular business  hours? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639065#M221432</link>
    <description>&lt;P&gt;Hi Splunkers,&lt;BR /&gt;&lt;BR /&gt;I want to create a search that send results to an "On call" system only for out of hours during monday to Friday from 5:30PM until the next day at 8:30AM and also 24h during the weekend starting on Friday at 5:30PM until Monday at 8:30AM. so basically I don't want to send any results during bussiness hours from 8:30AM till 5:30PM Mon-Friday.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am not sure if it's easier to set this up using cron time scheduler when I have my search ready or using earliest and latest&amp;nbsp; and some eval command within the search.&lt;BR /&gt;&lt;BR /&gt;Also wondering if this can be achieve within 1 search or should I create 1 for monday to friday and another one for the weekend given that the time ranges are different?&lt;BR /&gt;&lt;BR /&gt;Could Anyone have an idea how to best achieve this?&lt;BR /&gt;&lt;BR /&gt;Much appreciate it.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2023 16:44:12 GMT</pubDate>
    <dc:creator>JLopez</dc:creator>
    <dc:date>2023-04-10T16:44:12Z</dc:date>
    <item>
      <title>How to have Splunk search to include only events outside regular business  hours?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639065#M221432</link>
      <description>&lt;P&gt;Hi Splunkers,&lt;BR /&gt;&lt;BR /&gt;I want to create a search that send results to an "On call" system only for out of hours during monday to Friday from 5:30PM until the next day at 8:30AM and also 24h during the weekend starting on Friday at 5:30PM until Monday at 8:30AM. so basically I don't want to send any results during bussiness hours from 8:30AM till 5:30PM Mon-Friday.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am not sure if it's easier to set this up using cron time scheduler when I have my search ready or using earliest and latest&amp;nbsp; and some eval command within the search.&lt;BR /&gt;&lt;BR /&gt;Also wondering if this can be achieve within 1 search or should I create 1 for monday to friday and another one for the weekend given that the time ranges are different?&lt;BR /&gt;&lt;BR /&gt;Could Anyone have an idea how to best achieve this?&lt;BR /&gt;&lt;BR /&gt;Much appreciate it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 16:44:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639065#M221432</guid>
      <dc:creator>JLopez</dc:creator>
      <dc:date>2023-04-10T16:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search to include only events outside regular business  hours.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639069#M221433</link>
      <description>&lt;P&gt;Create a super-set cron covering of all of the times and then add logic to your SPL to short-circuit your search so that it errors on those times that aren't supposed to run. See my unaccepted answer here (UpVotes appreciated):&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/172541/is-it-possible-to-purposely-cause-a-scheduled-sear.html" rel="nofollow noopener noreferrer" target="_blank"&gt;https://answers.splunk.com/answers/172541/is-it-possible-to-purposely-cause-a-scheduled-sear.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Be aware that TZ is important here and depends on the Personal Settings of the user used to run the search!!!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 18:43:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639069#M221433</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-06T18:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search to include only events outside regular business  hours.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639103#M221441</link>
      <description>&lt;P&gt;Use a subsearch to dynamically generate pair of earliest/latest values. You can then conditionally generate time bounds for your search.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;PRE&gt;| tstats earliest_time(source) latest_time(source) where index=_internal&lt;BR /&gt;[ | makeresults &lt;BR /&gt;| eval earliest=now(),latest=now()&lt;BR /&gt;| eval earliest=if(earliest&amp;gt;2,earliest-100,earliest) &lt;BR /&gt;| eval search="earliest=".earliest." latest=".latest&lt;BR /&gt;|table search]&lt;/PRE&gt;&lt;P&gt;This subsearch initially generates earlies=latest=now(), which would yield no results at all. Then conditionally (the condition is always true of course in this case) rolls the earliest limit 100 seconds into the past so the search range for tstats effectively becomes "100s ago till now".&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 21:58:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639103#M221441</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-04-06T21:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search to include only events outside regular business  hours.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639156#M221456</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245749"&gt;@JLopez&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you need to filter events outside the office hours, the solution from&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;are the solution to your requirement.&lt;/P&gt;&lt;P&gt;If instead you want also manage holydays, you need a more complex solution.&lt;/P&gt;&lt;P&gt;In this case you need to create a lookup containing the holydays (called e.g. CAL) containing at least a column (called e.g. Holiday).&lt;/P&gt;&lt;P&gt;then you should run a search like the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| from datamodel:"Authentication" 
| eval Day=strftime(_time,"%d/%m/%Y"), WeekDay=strftime(_time,"%A"), Hours=strftime(_time,"%H")
| search [ | inputlookup SIEMCAL.csv | fields Day ] OR WeekDay="Saturday" OR Weekday="Sunday" OR Hours&amp;gt;18 OR Hours&amp;lt;8
| table _time user host&lt;/LI-CODE&gt;&lt;P&gt;Putting attention that the format of the Day column in the lookup is the same of the Day variable.&lt;/P&gt;&lt;P&gt;If you haven't the Authenticatin Datamodel, is more complex because you have to identify Login or Logfail or Logout events for all your platforms.&lt;/P&gt;&lt;P&gt;In addition you could put the subsearch for non working hours in a macro (called e.g. "NotWorkingTime") that you can call every time you need.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval Day=strftime(_time,"%d/%m/%Y"), WeekDay=strftime(_time,"%A"), Hours=strftime(_time,"%H")
| search [ | inputlookup SIEMCAL.csv | fields Day ] OR WeekDay="Saturday" OR Weekday="Sunday" OR Hours&amp;gt;18 OR Hours&amp;lt;8&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 05:56:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639156#M221456</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-04-07T05:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk search to include only events outside regular business  hours.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639956#M221759</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/245749"&gt;@JLopez&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;good for you, see next time!&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 by all the contributors &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2023 15:39:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-have-Splunk-search-to-include-only-events-outside-regular/m-p/639956#M221759</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-04-14T15:39:24Z</dc:date>
    </item>
  </channel>
</rss>

