<?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: Efficient and &amp;quot;correct&amp;quot; way to counting stats based on a *sequence* of events within a rolling timeframe in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384597#M112312</link>
    <description>&lt;P&gt;This is a bit tricky, but you could try going forward like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;base search&amp;gt;
| streamstats count(eval(Action=="Failure")) as failed count(eval(Action=="Success")) as succeeded last(Action) as last_action by SessionID
| eval status=case(failed&amp;gt;0 AND succeeded=0, "Failure_no_successs", failed=0 AND succeeded&amp;gt;0, "Success", failed&amp;gt;0 AND succeeded&amp;gt;0 AND last_action="Success", "Failure_then_success",true(),"other")
| stats count by status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 15 Feb 2019 15:52:27 GMT</pubDate>
    <dc:creator>DMohn</dc:creator>
    <dc:date>2019-02-15T15:52:27Z</dc:date>
    <item>
      <title>Efficient and "correct" way to counting stats based on a *sequence* of events within a rolling timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384595#M112310</link>
      <description>&lt;P&gt;Creating stats count based on a &lt;STRONG&gt;sequence&lt;/STRONG&gt; of events &lt;STRONG&gt;within a timeframe&lt;/STRONG&gt;.  For example, count the unique sessions, within a 6-hour timeframe, that resulted in 1- Failures without Success, 2- Success, or 3- Failures followed by Success:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SessionID   Time      Action
Abcd      12:03:11  Failure
Abcd      12:04:19  Failure
m        12:05:49   Failure
XXXXX    12:06:20   Failure
XXXXX   12:07:34    Failure
Abcd      12:10:11  Failure
Abcd      12:23:12  Success
ZZ      12:28:10    Success
XXXXX    12:31:00   Failure
Abcd      21:03:11  Success
m         22:03:11  Failure
m         22:03:12  Success
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Produces:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Failure_no_success | Success | Failure_then_success
    2              |   2     |       2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where Failure_no_success is the three XXXXX and the first m sessions, Success is the ZZ session and the last Abcd session, and Failure_then_success is the four Abcd and the last two m sessions.&lt;/P&gt;

&lt;P&gt;There are multiple inefficient ways to solve this, like combining many subsearches, outputing some of the data to a lookup table and reading it back, etc.  But is there a "correct" and scalable way to perform this count?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:14:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384595#M112310</guid>
      <dc:creator>mlorrette</dc:creator>
      <dc:date>2020-09-29T23:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient and "correct" way to counting stats based on a *sequence* of events within a rolling timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384596#M112311</link>
      <description>&lt;P&gt;A starting point is a distinct count with a  &lt;CODE&gt;timechart dc(sessionID) span=6h&lt;/CODE&gt;.  I dont know how to do the multiple sequence events&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 15:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384596#M112311</guid>
      <dc:creator>JaoelNameiol</dc:creator>
      <dc:date>2019-02-15T15:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient and "correct" way to counting stats based on a *sequence* of events within a rolling timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384597#M112312</link>
      <description>&lt;P&gt;This is a bit tricky, but you could try going forward like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;base search&amp;gt;
| streamstats count(eval(Action=="Failure")) as failed count(eval(Action=="Success")) as succeeded last(Action) as last_action by SessionID
| eval status=case(failed&amp;gt;0 AND succeeded=0, "Failure_no_successs", failed=0 AND succeeded&amp;gt;0, "Success", failed&amp;gt;0 AND succeeded&amp;gt;0 AND last_action="Success", "Failure_then_success",true(),"other")
| stats count by status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Feb 2019 15:52:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384597#M112312</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-15T15:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient and "correct" way to counting stats based on a *sequence* of events within a rolling timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384598#M112313</link>
      <description>&lt;P&gt;Almost but not there.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval status=case(failed&amp;gt;0 AND succeeded=0, "Failure_no_successs", failed=0 AND succeeded&amp;gt;0, "Success", failed&amp;gt;0 AND succeeded&amp;gt;0 AND last_action="Success", "Failure_then_success",true(),"other")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Doesn't evaluate the Failure_then_success and marks it as Success.  I'll dig deeper using &lt;CODE&gt;streamstats&lt;/CODE&gt;  There's also no grouping by time (6 hours)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:17:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384598#M112313</guid>
      <dc:creator>mlorrette</dc:creator>
      <dc:date>2020-09-29T23:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient and "correct" way to counting stats based on a *sequence* of events within a rolling timeframe</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384599#M112314</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval raw="SessionID=Abcd,Time=12:03:11,Action=Failure SessionID=Abcd,Time=12:04:19,Action=Failure SessionID=m,Time=12:05:49,Action=Failure SessionID=XXXXX,Time=12:06:20,Action=Failure SessionID=XXXXX,Time=12:07:34,Action=Failure SessionID=Abcd,Time=12:10:11,Action=Failure SessionID=Abcd,Time=12:23:12,Action=Success SessionID=ZZ,Time=12:28:10,Action=Success SessionID=XXXXX,Time=12:31:00,Action=Failure SessionID=Abcd,Time=21:03:11,Action=Success SessionID=m,Time=22:03:11,Action=Failure SessionID=m,Time=22:03:12,Action=Success"
| makemv raw
| mvexpand raw
| rename raw AS _raw
| streamstats count
| eval Time = strptime(Time, "%H:%M:%S")
| fields - count
| kv

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| stats list(Action) AS Action list(Time) AS Time count(eval(Action="Success")) AS SuccessCount count(eval(Action="Failure")) AS FailureCount BY SessionID
| eval category=case(
   ((SuccessCount==0) AND (FailureCount&amp;gt;0)), "FailureNoSuccess",
   ((SuccessCount&amp;gt;0) AND (FailureCount==0)), "Success",
   ((SuccessCount&amp;gt;0) AND (FailureCount&amp;gt;0)), "FailureThenSuccess",
   true(), "UNKNOWN")
| eval foo="bar"
| chart dc(SessionID) BY foo category
| table FailureNoSuccess Success FailureThenSuccess
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Mar 2019 14:47:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Efficient-and-quot-correct-quot-way-to-counting-stats-based-on-a/m-p/384599#M112314</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-11T14:47:23Z</dc:date>
    </item>
  </channel>
</rss>

