<?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: Define condition per timeframe in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391185#M113897</link>
    <description>&lt;P&gt;you can convert your &lt;CODE&gt;_time&lt;/CODE&gt; like this &lt;CODE&gt;| eval TimeOfTheday=strftime(_time,"%R%p")&lt;/CODE&gt; and then again use the &lt;CODE&gt;case&lt;/CODE&gt; of &lt;CODE&gt;if&lt;/CODE&gt; conditions to put the time(hour) in the right &lt;CODE&gt;buckets&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Or You could first create epoch time for &lt;CODE&gt;6pm&lt;/CODE&gt; and &lt;CODE&gt;7am&lt;/CODE&gt; like this &lt;CODE&gt;| eval StartTime=strptime("18:00","%H:%M")&lt;/CODE&gt;  and &lt;CODE&gt;| eval StartTime=strptime("07:00","%H:%M")&lt;/CODE&gt; and then apply &lt;CODE&gt;if&lt;/CODE&gt;&lt;CODE&gt;else&lt;/CODE&gt; :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=smth EventCode=4625 Account_Domain="*" 
| fillnull value=NULL 
| eval Account_Name = mvindex(Account_Name,1) 
| eval LoginType=case(Logon_Type=3,"RPC (not RDP)",Logon_Type=4,"Batch",Logon_Type=5,"Service",Logon_Type=7,"Screen Unlock/Session Resume",Logon_Type=10,"Remote Desktop",Logon_Type=11,"Cached",Logon_Type=9,"New Credentials") 
| stats count by host, Account_Name, LoginType, _time, Account_Domain 
| sort -count 
| eval StartTime=strptime("18:00","%H:%M") 
| eval EndTime=strptime("22:00","%H:%M") | eval Buckets=if(_time&amp;gt;StartTime AND _time&amp;lt;EndTime,"6PM to 7 AM",EverythingElse)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Feb 2019 18:33:01 GMT</pubDate>
    <dc:creator>macadminrohit</dc:creator>
    <dc:date>2019-02-19T18:33:01Z</dc:date>
    <item>
      <title>Define condition per timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391183#M113895</link>
      <description>&lt;P&gt;Hi there, &lt;/P&gt;

&lt;P&gt;I hope for some help with a query. &lt;/P&gt;

&lt;P&gt;I'm using the following query to get a list of all failed login attempts and so far it works. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=smth EventCode=4625 Account_Domain="*"
 |fillnull value=NULL
 |eval Account_Name = mvindex(Account_Name,1) 
 |eval LoginType=case(Logon_Type=3,"RPC (not RDP)",Logon_Type=4,"Batch",Logon_Type=5,"Service",Logon_Type=7,"Screen Unlock/Session Resume",Logon_Type=10,"Remote Desktop",Logon_Type=11,"Cached",Logon_Type=9,"New Credentials")
 |stats count by host, Account_Name, LoginType, _time, Account_Domain
 |sort -count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd like to check whether it's possible to define additional condition based on predefined timeframes. &lt;/P&gt;

&lt;P&gt;For example, I want to list all failed logins for domain RUSSIA for Russia's out of office hours "from 6pm to 7am"&lt;BR /&gt;
Then the same condition but for ASIA and so on. &lt;/P&gt;

&lt;P&gt;So, the condition will be - if failed login domain equals RUSSIA and timeframe equals (predefined value) then show in the report.&lt;/P&gt;

&lt;P&gt;Hope it's clear what I want to do &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 14:09:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391183#M113895</guid>
      <dc:creator>swimena</dc:creator>
      <dc:date>2019-02-19T14:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Define condition per timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391184#M113896</link>
      <description>&lt;P&gt;YOu do have the _time value in your final result, so you can extract hour value from it (or time of day), then you can have  &lt;CODE&gt;eval-case&lt;/CODE&gt; to assign the count to different field based on Account_Domain and hour values.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:22:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391184#M113896</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T23:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Define condition per timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391185#M113897</link>
      <description>&lt;P&gt;you can convert your &lt;CODE&gt;_time&lt;/CODE&gt; like this &lt;CODE&gt;| eval TimeOfTheday=strftime(_time,"%R%p")&lt;/CODE&gt; and then again use the &lt;CODE&gt;case&lt;/CODE&gt; of &lt;CODE&gt;if&lt;/CODE&gt; conditions to put the time(hour) in the right &lt;CODE&gt;buckets&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Or You could first create epoch time for &lt;CODE&gt;6pm&lt;/CODE&gt; and &lt;CODE&gt;7am&lt;/CODE&gt; like this &lt;CODE&gt;| eval StartTime=strptime("18:00","%H:%M")&lt;/CODE&gt;  and &lt;CODE&gt;| eval StartTime=strptime("07:00","%H:%M")&lt;/CODE&gt; and then apply &lt;CODE&gt;if&lt;/CODE&gt;&lt;CODE&gt;else&lt;/CODE&gt; :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=smth EventCode=4625 Account_Domain="*" 
| fillnull value=NULL 
| eval Account_Name = mvindex(Account_Name,1) 
| eval LoginType=case(Logon_Type=3,"RPC (not RDP)",Logon_Type=4,"Batch",Logon_Type=5,"Service",Logon_Type=7,"Screen Unlock/Session Resume",Logon_Type=10,"Remote Desktop",Logon_Type=11,"Cached",Logon_Type=9,"New Credentials") 
| stats count by host, Account_Name, LoginType, _time, Account_Domain 
| sort -count 
| eval StartTime=strptime("18:00","%H:%M") 
| eval EndTime=strptime("22:00","%H:%M") | eval Buckets=if(_time&amp;gt;StartTime AND _time&amp;lt;EndTime,"6PM to 7 AM",EverythingElse)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Feb 2019 18:33:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391185#M113897</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2019-02-19T18:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Define condition per timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391186#M113898</link>
      <description>&lt;P&gt;Perfect, thank you very much. I set it up for all the domains and it works like a charm. &lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 06:34:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Define-condition-per-timeframe/m-p/391186#M113898</guid>
      <dc:creator>swimena</dc:creator>
      <dc:date>2019-02-20T06:34:27Z</dc:date>
    </item>
  </channel>
</rss>

