<?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: Find records within a timeframe defined by another search. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Find-records-within-a-timeframe-defined-by-another-search/m-p/20420#M3189</link>
    <description>&lt;P&gt;Sounds like you have two sets of events - one for order_requests, and one that is the users actually accessing the system. &lt;/P&gt;

&lt;P&gt;Let me assume that these are two different sourcetypes,  and also that the userId is extracted as the same field name in each sourcetype,  eg: &lt;CODE&gt;userId&lt;/CODE&gt; (if not you would use a little more conditional eval to make yourself a single normalized field). &lt;/P&gt;

&lt;P&gt;Lets also say that the order_request events have two fields - &lt;CODE&gt;requested_start&lt;/CODE&gt; and &lt;CODE&gt;requested_end&lt;/CODE&gt;, defining the interval of the requested access time. &lt;/P&gt;

&lt;P&gt;Then this search would give you the usernames who had accessed the system outside of the allowed timerange, and their various times of the unauthorized access.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=order_request OR sourcetype=access 
| eval access_time=if(sourcetype=="access",_time,null()) 
| stats last(requested_start) as start last(requested_end) as end values(access_time) as access_time by userId
| mvexpand access_time
| where access_time&amp;gt;end OR access_time&amp;lt;start
| table userId start end access_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Sep 2020 13:14:28 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2020-09-28T13:14:28Z</dc:date>
    <item>
      <title>Find records within a timeframe defined by another search.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-records-within-a-timeframe-defined-by-another-search/m-p/20419#M3188</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;we have this scenario:&lt;/P&gt;

&lt;P&gt;User is login in to a system on date A.&lt;BR /&gt;
To be allowed to do so he/she has to order access. From date X to date Y.&lt;/P&gt;

&lt;P&gt;So we have no find all order requests from that user and find out if the date A is in the timeframe from X and Y.&lt;/P&gt;

&lt;P&gt;Kind Regards,&lt;/P&gt;

&lt;P&gt;jens&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2013 16:27:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-records-within-a-timeframe-defined-by-another-search/m-p/20419#M3188</guid>
      <dc:creator>JensT</dc:creator>
      <dc:date>2013-02-05T16:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Find records within a timeframe defined by another search.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-records-within-a-timeframe-defined-by-another-search/m-p/20420#M3189</link>
      <description>&lt;P&gt;Sounds like you have two sets of events - one for order_requests, and one that is the users actually accessing the system. &lt;/P&gt;

&lt;P&gt;Let me assume that these are two different sourcetypes,  and also that the userId is extracted as the same field name in each sourcetype,  eg: &lt;CODE&gt;userId&lt;/CODE&gt; (if not you would use a little more conditional eval to make yourself a single normalized field). &lt;/P&gt;

&lt;P&gt;Lets also say that the order_request events have two fields - &lt;CODE&gt;requested_start&lt;/CODE&gt; and &lt;CODE&gt;requested_end&lt;/CODE&gt;, defining the interval of the requested access time. &lt;/P&gt;

&lt;P&gt;Then this search would give you the usernames who had accessed the system outside of the allowed timerange, and their various times of the unauthorized access.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=order_request OR sourcetype=access 
| eval access_time=if(sourcetype=="access",_time,null()) 
| stats last(requested_start) as start last(requested_end) as end values(access_time) as access_time by userId
| mvexpand access_time
| where access_time&amp;gt;end OR access_time&amp;lt;start
| table userId start end access_time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-records-within-a-timeframe-defined-by-another-search/m-p/20420#M3189</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2020-09-28T13:14:28Z</dc:date>
    </item>
  </channel>
</rss>

