<?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: How To Exclude Events from Transaction if there is Time Gap Larger than X in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553969#M157257</link>
    <description>&lt;P&gt;Hi, thanks for the response but unfortunately that won't help me in this case. I don't care how long the transaction is, it could be over an hour long or only a few seconds, but what matters is being able to exclude events from being the starting event if the next potential starting event is greater than 5 minutes away.&lt;/P&gt;&lt;P&gt;So if I have:&lt;/P&gt;&lt;P&gt;2021-06-01 14:43:01 UserId:123 Leave LocationId:6722&lt;BR /&gt;2021-06-01 14:43:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:42:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:41:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:40:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:39:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:38:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:32:32 UserId:123 Reserve LocationId:6722&lt;/P&gt;&lt;P&gt;Then I want to exclude the last event because the gap between that event and the next event with the same location id is greater than 5 minutes.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Jun 2021 21:02:21 GMT</pubDate>
    <dc:creator>Traer001</dc:creator>
    <dc:date>2021-06-01T21:02:21Z</dc:date>
    <item>
      <title>How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553966#M157255</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am creating transactions for the earliest instance of a location being reserved and that location being released. However, I want to be able to exclude events that have a time gap greater than a set amount of time (maybe 5 minutes) between the earliest instance of reservation and any subsequent instances of reservation. For example, my events for a user might appear like this:&lt;/P&gt;&lt;P&gt;2021-06-01 14:41:12 UserId:123 Leave LocationId:6722&lt;BR /&gt;2021-06-01 14:40:43 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:40:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:33:10 UserId:123 Leave LocationId:9035&lt;BR /&gt;2021-06-01 14:32:44 UserId:123 Reserve LocationId:9035&lt;BR /&gt;2021-06-01 14:32:36 UserId:123 Reserve LocationId:9035&lt;BR /&gt;2021-06-01 14:32:32 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:32:08 UserId:123 Leave LocationId:3451&lt;BR /&gt;2021-06-01 14:31:47 UserId:123 Reserve LocationId:3451&lt;BR /&gt;2021-06-01 14:31:25 UserId:123 Reserve LocationId:3451&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now instead of retrieving a transaction for location id: 6722 at 14:32:32 and 14:41:12, I want it to retrieve the events at 14:40:01 and 14:41:12 and exclude the event at 14:32:32 because it occurred more than 5 minutes ago.&lt;/P&gt;&lt;P&gt;How should I go about this?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 20:48:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553966#M157255</guid>
      <dc:creator>Traer001</dc:creator>
      <dc:date>2021-06-01T20:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553967#M157256</link>
      <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;transaction command has option for that. You should look parameter&amp;nbsp;&lt;SPAN&gt;maxspan&amp;nbsp;&lt;/SPAN&gt;on&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.0/SearchReference/Transaction" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.0/SearchReference/Transaction&lt;/A&gt;&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 20:51:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553967#M157256</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-06-01T20:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553969#M157257</link>
      <description>&lt;P&gt;Hi, thanks for the response but unfortunately that won't help me in this case. I don't care how long the transaction is, it could be over an hour long or only a few seconds, but what matters is being able to exclude events from being the starting event if the next potential starting event is greater than 5 minutes away.&lt;/P&gt;&lt;P&gt;So if I have:&lt;/P&gt;&lt;P&gt;2021-06-01 14:43:01 UserId:123 Leave LocationId:6722&lt;BR /&gt;2021-06-01 14:43:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:42:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:41:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:40:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:39:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:38:01 UserId:123 Reserve LocationId:6722&lt;BR /&gt;2021-06-01 14:32:32 UserId:123 Reserve LocationId:6722&lt;/P&gt;&lt;P&gt;Then I want to exclude the last event because the gap between that event and the next event with the same location id is greater than 5 minutes.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 21:02:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553969#M157257</guid>
      <dc:creator>Traer001</dc:creator>
      <dc:date>2021-06-01T21:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553972#M157258</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="2021-06-01 14:41:12 UserId:123 Leave LocationId:6722
2021-06-01 14:40:43 UserId:123 Reserve LocationId:6722
2021-06-01 14:40:01 UserId:123 Reserve LocationId:6722
2021-06-01 14:33:10 UserId:123 Leave LocationId:9035
2021-06-01 14:32:44 UserId:123 Reserve LocationId:9035
2021-06-01 14:32:36 UserId:123 Reserve LocationId:9035
2021-06-01 14:32:32 UserId:123 Reserve LocationId:6722
2021-06-01 14:32:08 UserId:123 Leave LocationId:3451
2021-06-01 14:31:47 UserId:123 Reserve LocationId:3451
2021-06-01 14:31:25 UserId:123 Reserve LocationId:3451"
| multikv noheader=t
| rex "(?&amp;lt;time&amp;gt;\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d)\sUserId:(?&amp;lt;userid&amp;gt;\d+)\s(?&amp;lt;action&amp;gt;\w+)\sLocationId:(?&amp;lt;locationid&amp;gt;\d+)"
| eval _time=strptime(time,"%Y-%m-%d %H:%M:%S")
| fields _time userid action locationid


| transaction locationid maxspan=5m endswith="Leave"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 01 Jun 2021 21:12:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553972#M157258</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-01T21:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553973#M157259</link>
      <description>Sorry for previous, now I probably got what you are meaning. I think that this can be do with streamstats with window, reset* etc.?&lt;BR /&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.0/SearchReference/Streamstats" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/8.2.0/SearchReference/Streamstats&lt;/A&gt;&lt;BR /&gt;I cannot try it now, maybe later or if you or someone else cannot figure it out before that.&lt;BR /&gt;r. Ismo</description>
      <pubDate>Tue, 01 Jun 2021 21:12:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553973#M157259</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2021-06-01T21:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553978#M157260</link>
      <description>&lt;P&gt;Hello, thank you for the response. Unfortunately, this is not working for longer transactions (ones that exceed 5 minutes). I don't care how long the transaction is (can be a few seconds or longer than an hour), but what matters is that the starting event does not have a gap of more than 5 minutes between it and another "Reserve" action. I posted another example as a comment to soutamo's post.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 21:34:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553978#M157260</guid>
      <dc:creator>Traer001</dc:creator>
      <dc:date>2021-06-01T21:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553980#M157261</link>
      <description>&lt;P&gt;I understand, and thank you! Any help would be appreciated! This is what I have right now:&lt;/P&gt;&lt;P&gt;index=INDEX host=HOST sourcetype=SOURCETYPE&lt;BR /&gt;| rex field=_raw "UserId:(?&amp;lt;user_id&amp;gt;\d+)\sReserve\sLocationId:(?&amp;lt;loc&amp;gt;\d+)"&lt;BR /&gt;| rex field=_raw "UserId:(?&amp;lt;user_id&amp;gt;\d+)\sLeave\sLocationId:(?&amp;lt;loc&amp;gt;\d+)"&lt;BR /&gt;| eval action=if(like(_raw, "%Reserve%"), "Reserved", (if(like(_raw, "%Leave%"), "Left", null)))&lt;BR /&gt;| where isnotnull(action)&lt;BR /&gt;| sort 0 user_id loc _time&lt;BR /&gt;| streamstats count as count_value by loc user_id action reset_on_change=true&lt;BR /&gt;| where count_value=1&lt;BR /&gt;| transaction user_id loc startswith="Reserve" endswith="Leave"&lt;BR /&gt;| eval begin=_time&lt;BR /&gt;| eval leave_time=strftime(begin+duration,"%Y-%m-%d %H:%M:%S")&lt;BR /&gt;| eval reserve_time=strftime(begin,"%Y-%m-%d %H:%M:%S")&lt;BR /&gt;| where duration&amp;gt;0 and user_id&amp;lt;=3000&lt;BR /&gt;| eval duration=tostring(duration, "duration")&lt;BR /&gt;| table user_id, loc, reserve_time, leave_time, duration&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But of course, I am struggling with setting it up in the desired fashion to exclude the previously mentioned events.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 21:46:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553980#M157261</guid>
      <dc:creator>Traer001</dc:creator>
      <dc:date>2021-06-01T21:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553983#M157262</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="2021-06-01 14:43:01 UserId:123 Leave LocationId:6722
2021-06-01 14:43:01 UserId:123 Reserve LocationId:6722
2021-06-01 14:42:01 UserId:123 Reserve LocationId:6722
2021-06-01 14:41:01 UserId:123 Reserve LocationId:6722
2021-06-01 14:40:01 UserId:123 Reserve LocationId:6722
2021-06-01 14:39:01 UserId:123 Reserve LocationId:6722
2021-06-01 14:38:01 UserId:123 Reserve LocationId:6722
2021-06-01 14:32:32 UserId:123 Reserve LocationId:6722"
| multikv noheader=t
| rex "(?&amp;lt;time&amp;gt;\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d)\sUserId:(?&amp;lt;userid&amp;gt;\d+)\s(?&amp;lt;action&amp;gt;\w+)\sLocationId:(?&amp;lt;locationid&amp;gt;\d+)"
| eval _time=strptime(time,"%Y-%m-%d %H:%M:%S")
| fields _time userid action locationid


| transaction locationid maxpause=5m endswith="Leave"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 01 Jun 2021 22:28:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/553983#M157262</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-01T22:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: How To Exclude Events from Transaction if there is Time Gap Larger than X</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/554026#M157277</link>
      <description>&lt;P&gt;You probably should try two transaction commands in sequence, with different constraints. The first one will collect all the reserve events with the same user_id and loc, but will not add events to the transaction if they occurred more than 5 minutes away from any other event. You use maxpause instead of maxspan. You probably need to keep evicted and orphaned transactions so all events are still available for the second transaction. For the first transaction we only want "Reserve" events to be merged. The second transaction merges the "Leave" and "Reserve" events&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| transaction user_id loc action startswith="Reserve" endswith="Reserve" maxpause=5m keepevicted=true keeporphans=true&lt;BR /&gt;| transaction user_id loc&amp;nbsp;startswith="Reserve" endswith="Leave" maxevents=2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The maxevents=2 is important so that the Reserve events &amp;gt; 5 minutes early, that were separated out by the first transaction, don't get added back into the second transaction.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 05:20:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-To-Exclude-Events-from-Transaction-if-there-is-Time-Gap/m-p/554026#M157277</guid>
      <dc:creator>fredchase</dc:creator>
      <dc:date>2021-06-02T05:20:44Z</dc:date>
    </item>
  </channel>
</rss>

