<?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 find a follow-up event after certain interval in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489019#M136595</link>
    <description>&lt;P&gt;Say, when a user connects his VPN, it will do policy checking (event--&amp;gt; policy_checking) and within 5 minutes will be completed (event--&amp;gt; policy_checking_completed) and allows the user to connect through the VPN, till then it becomes complied policy_checking events will be generated.&lt;/P&gt;

&lt;P&gt;If the &lt;STRONG&gt;policy_checking_completed&lt;/STRONG&gt; event is not generated in 5 minutes we need to get an alert. If the VPN goes down because of the poor connection or anything else; then it will go through the policy check again.&lt;/P&gt;

&lt;P&gt;My search is like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vpn [search index=vpn policy="policy_checking" | eval earliest=_time | eval latest=_time+300 | fields earliest,latest, Name] | eval status = if(policy="policy_checking_completed",1,0) | eventstats sum(status) as statscount by Name  |  table _time Name policy statscount | search statscount=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We have used bin span=5m but it checks the values between 09:00 and 09:05 (NOT 09:03 and 09:08).&lt;/P&gt;

&lt;P&gt;This search works fine for if the system generates has one set of events, if the user has multiple disconnection and re-connection say in 1 hr, the search will go for a toss because of statscount. &lt;/P&gt;

&lt;P&gt;Is there any other workaround?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 03:03:45 GMT</pubDate>
    <dc:creator>cyber_castle</dc:creator>
    <dc:date>2020-09-30T03:03:45Z</dc:date>
    <item>
      <title>How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489019#M136595</link>
      <description>&lt;P&gt;Say, when a user connects his VPN, it will do policy checking (event--&amp;gt; policy_checking) and within 5 minutes will be completed (event--&amp;gt; policy_checking_completed) and allows the user to connect through the VPN, till then it becomes complied policy_checking events will be generated.&lt;/P&gt;

&lt;P&gt;If the &lt;STRONG&gt;policy_checking_completed&lt;/STRONG&gt; event is not generated in 5 minutes we need to get an alert. If the VPN goes down because of the poor connection or anything else; then it will go through the policy check again.&lt;/P&gt;

&lt;P&gt;My search is like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vpn [search index=vpn policy="policy_checking" | eval earliest=_time | eval latest=_time+300 | fields earliest,latest, Name] | eval status = if(policy="policy_checking_completed",1,0) | eventstats sum(status) as statscount by Name  |  table _time Name policy statscount | search statscount=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We have used bin span=5m but it checks the values between 09:00 and 09:05 (NOT 09:03 and 09:08).&lt;/P&gt;

&lt;P&gt;This search works fine for if the system generates has one set of events, if the user has multiple disconnection and re-connection say in 1 hr, the search will go for a toss because of statscount. &lt;/P&gt;

&lt;P&gt;Is there any other workaround?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:03:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489019#M136595</guid>
      <dc:creator>cyber_castle</dc:creator>
      <dc:date>2020-09-30T03:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489020#M136596</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index=vpn policy="policy_checking" OR policy="policy_checking_completed"
| reverse
| streamstats count(eval(policy="policy_checking_completed")) as count by Name
| eventstats range(_time) as duration by count Name
| where duration &amp;gt; 300
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, It might be a little different, but what about this query?&lt;BR /&gt;
Displays events that have taken more than 5 minutes to complete.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2019 08:10:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489020#M136596</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-23T08:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489021#M136597</link>
      <description>&lt;P&gt;Thanks a lot for your feedback. I appreciate your efforts. Pls excuse, if I was not fully clear on my requirement.&lt;/P&gt;

&lt;P&gt;I have seen few challenges.  Pls refer the following table&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;After _time:15:02:45:723 it is not failing because as per the requirement we need to get alert the 5minutes failure.&lt;/LI&gt;
&lt;LI&gt;If we look for _time 15:13:21.932 &amp;amp; 15:15:36.827 duration is 1196.771 but in reference to 15:13:21.932, policy is complied and the user is allowed to connect to VPN.&lt;/LI&gt;
&lt;LI&gt;If we look for 15:47:57.127 it was policy_checking and 15:48:28.549 it is complied so the count should be zero.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Date        _time           duration     count         policy&lt;BR /&gt;
1.2019-10-23 15:01:18.965           722.967     0      policy_checking&lt;BR /&gt;
2. 2019-11-22 15:02:03.260  722.967   0   policy_checking&lt;BR /&gt;
3. 2019-11-22 15:02:45.723  722.967   0   policy_checking&lt;BR /&gt;
4. 2019-11-22 15:13:21.932  722.967   0   policy_checking&lt;BR /&gt;
5. 2019-11-22 15:15:36.827  1196.771  1   policy_checking_completed&lt;BR /&gt;
6. 2019-11-22 15:35:33.598  1196.771  1   policy_checking&lt;BR /&gt;
7. 2019-11-22 15:36:08.765  708.362   2   policy_checking_completed&lt;BR /&gt;
8. 2019-11-22 15:47:57.127  708.362   2   policy_checking&lt;BR /&gt;
9. 2019-11-22 15:48:28.549  0.000     3   policy_checking_completed&lt;BR /&gt;
10. 2019-11-22 15:48:31.468 204.786   4   policy_checking_completed&lt;BR /&gt;
11. 2019-11-22 15:51:06.414 204.786   4   policy_checking&lt;BR /&gt;
12. 2019-11-22 15:51:39.921 204.786   4   policy_checking&lt;BR /&gt;
13. 2019-11-22 15:51:56.254     204.786   4   policy_checking&lt;/P&gt;

&lt;P&gt;The issue with me is that, we need to start the search when it sees the first policy_checking and wait for 5 minutes to see policy_checking_completed. If not send me an alert. Then the counter need to reset to Zero. Whatever comes after it need to be considered as a fresh one.&lt;/P&gt;

&lt;P&gt;Also, we have large volume of data so I am not sure whether reverse command is efficient or not?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489021#M136597</guid>
      <dc:creator>cyber_castle</dc:creator>
      <dc:date>2020-09-30T03:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489022#M136598</link>
      <description>&lt;P&gt;You need &lt;CODE&gt;streamstats&lt;/CODE&gt;; try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vpn AND (policy="policy_checking" OR policy="policy_checking_completed")
| streamstats count(eval(policy="policy_checking_completed")) AS sessionID BY Name
| stats min(_time) AS _time range(_time) AS duration values(policy) AS policy dc(policy) as policy_count BY sessionID Name
| where policy="policy_checking" AND policy_count==1
| eval waiting = now() - _time
| where waiting &amp;gt;= (5 * 60)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Nov 2019 18:09:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489022#M136598</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-23T18:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489023#M136599</link>
      <description>&lt;P&gt;Thanks a lot for your feedback. &lt;/P&gt;

&lt;P&gt;Nearly perfect.. the only issue which i have found was that.. (pls refer the table which i have posted yesterday) for the first set it starts at 15:01:18 and ends at 15:02:45.72 (3 policy_checking events) it didnt get captured as a separate one; instead it went till 15:15:36.827 (5 events: 4 policy_checking event, 1 policy_checking_completed).&lt;/P&gt;

&lt;TABLE&gt;&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH&gt;sessionID&lt;/TH&gt;
&lt;TH style="text-align: center"&gt;Name    _&lt;/TH&gt;
&lt;TH style="text-align: center"&gt;time&lt;/TH&gt;
&lt;TH style="text-align: center"&gt;duration&lt;/TH&gt;
&lt;TH style="text-align: center"&gt;policy&lt;/TH&gt;
&lt;TH style="text-align: center"&gt;policy_count&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;Laptop&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;2019-11-23 15:15:36.826&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;857.862&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;policy_checking policy_checking_completed&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;Laptop&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;2019-11-23 15:36:08.765&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;35.167&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;policy_checking policy_checking_completed&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;Laptop&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;2019-11-23 15:48:28.549&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;31.422&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;policy_checking     policy_checking_completed&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;Laptop&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;2019-11-23 15:48:31.467&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;0.000&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;policy_checking_completed&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;Laptop&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;2019-11-23 15:51:56.253&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;49.840&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;policy_checking&lt;/TD&gt;
&lt;TD style="text-align: center"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:04:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489023#M136599</guid>
      <dc:creator>cyber_castle</dc:creator>
      <dc:date>2020-09-30T03:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489024#M136600</link>
      <description>&lt;P&gt;Try this then:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=vpn AND (policy="policy_checking" OR policy="policy_checking_completed")
| reverse
| streamstats count(eval(policy="policy_checking")) AS sessionID BY Name
| stats min(_time) AS _time range(_time) AS duration values(policy) AS policy dc(policy) as policy_count BY sessionID Name
| where policy="policy_checking" AND policy_count==1
| eval waiting = now() - _time
| where waiting &amp;gt;= (5 * 60)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Nov 2019 19:34:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489024#M136600</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-25T19:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489025#M136601</link>
      <description>&lt;P&gt;Thanks woodcock. But it will skew the last entries. I have last 3 events as policy_checking and its not getting picked up.  Also, I feel duration is also not correct. Why the duration is 1196 for the time 15:15:36&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;15:01:18.965  722   policy_checking 
15:02:03.260        policy_checking 
15:02:45.723        policy_checking 
15:13:21.932        policy_checking 
15:15:36.827 1196   policy_checking_completed   
15:35:33.598        policy_checking 
15:36:08.765 708    policy_checking_completed
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Nov 2019 20:23:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489025#M136601</guid>
      <dc:creator>cyber_castle</dc:creator>
      <dc:date>2019-11-26T20:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489026#M136602</link>
      <description>&lt;P&gt;I am sure that I can meet your edge cases if you will supply appropriate sample events.  Otherwise we will be doing this dance forever.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2019 00:09:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489026#M136602</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-27T00:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a follow-up event after certain interval</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489027#M136603</link>
      <description>&lt;P&gt;I just tested and I stand by my last answer.  Here is a run-anywhere proof based on the data that you provided in previous comment:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="time=15:01:18.965 foo=722 policy=policy_checking    
time=15:02:03.260 policy=policy_checking    
time=15:02:45.723 policy=policy_checking    
time=15:13:21.932 policy=policy_checking    
time=15:15:36.827 foo=1196 policy=policy_checking_completed    
time=15:35:33.598 policy=policy_checking    
time=15:36:08.765 foo=708 policy=policy_checking_completed" 
| makemv delim="
" raw
| mvexpand raw
| rename raw AS _raw
| kv
| eval _time = strptime(time, "%H:%M:%S.%3N"), Name = "Name"
| sort 0 - _time 
| table _time Name foo policy

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| reverse
| streamstats count(eval(policy="policy_checking")) AS sessionID BY Name
| stats min(_time) AS _time range(_time) AS duration values(policy) AS policy dc(policy) as policy_count count BY sessionID Name
| where policy="policy_checking" AND policy_count==1
| eval waiting = now() - _time
| where waiting &amp;gt;= (5 * 60)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Nov 2019 00:26:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-a-follow-up-event-after-certain-interval/m-p/489027#M136603</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-27T00:26:57Z</dc:date>
    </item>
  </channel>
</rss>

