<?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: Is there a way to detect a particular series of consecutive events that are interrupted by other events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-detect-a-particular-series-of-consecutive/m-p/388082#M113167</link>
    <description>&lt;P&gt;Is it just A -&amp;gt; B -&amp;gt; A to be detected what about  B -&amp;gt;  A -&amp;gt; B or any other combinations of events?&lt;/P&gt;</description>
    <pubDate>Fri, 21 Sep 2018 17:35:43 GMT</pubDate>
    <dc:creator>msivill_splunk</dc:creator>
    <dc:date>2018-09-21T17:35:43Z</dc:date>
    <item>
      <title>Is there a way to detect a particular series of consecutive events that are interrupted by other events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-detect-a-particular-series-of-consecutive/m-p/388081#M113166</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Is there a way to detect a particular series of consecutive events that are interrupted by other events?&lt;/P&gt;

&lt;P&gt;I have data like...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;timestamp   Event
01.01.2018  A
02.01.2018  X
03.01.2018  X
04.01.2018  B
05.01.2018  X
06.01.2018  X
07.01.2018  X
08.01.2018  B
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...and I want to detect the sequences A B A, which I would add as a flag field.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 14:38:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-detect-a-particular-series-of-consecutive/m-p/388081#M113166</guid>
      <dc:creator>juliafum</dc:creator>
      <dc:date>2018-09-21T14:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to detect a particular series of consecutive events that are interrupted by other events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-detect-a-particular-series-of-consecutive/m-p/388082#M113167</link>
      <description>&lt;P&gt;Is it just A -&amp;gt; B -&amp;gt; A to be detected what about  B -&amp;gt;  A -&amp;gt; B or any other combinations of events?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 17:35:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-detect-a-particular-series-of-consecutive/m-p/388082#M113167</guid>
      <dc:creator>msivill_splunk</dc:creator>
      <dc:date>2018-09-21T17:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to detect a particular series of consecutive events that are interrupted by other events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-detect-a-particular-series-of-consecutive/m-p/388083#M113168</link>
      <description>&lt;P&gt;There are two different parts to your question.&lt;/P&gt;

&lt;P&gt;First, can you detect a series of events that have other events interspersed?  Yes, of course.  &lt;/P&gt;

&lt;P&gt;Second, can you "mark" them or flag them?   In a search, yes.  However, not in terms of a data model or tags, since those are based on individual events.&lt;/P&gt;

&lt;P&gt;In order to give you the best advices, we would need more information on the sequence.  You said &lt;CODE&gt;A &amp;gt; B &amp;gt; A&lt;/CODE&gt;, but your data shows only &lt;CODE&gt;A &amp;gt; B &amp;gt; B&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;This search is likely to use a &lt;CODE&gt;streamstats&lt;/CODE&gt; command of some sort.&lt;/P&gt;

&lt;P&gt;Let's suppose you only care when an &lt;CODE&gt;A&lt;/CODE&gt; changes to &lt;CODE&gt;B&lt;/CODE&gt; or back to &lt;CODE&gt;A&lt;/CODE&gt;.  Here's a run-anywhere example that marks the records you want to flag.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval mydata="01.01.2018,A;02.01.2018,X;03.01.2018,Q;04.01.2018,B;05.01.2018,G;06.01.2018,X;07.01.2018,R;08.01.2018,B;09.01.2018,A;"
| makemv delim=";" mydata
| mvexpand mydata
| makemv delim="," mydata
| eval _time=strptime(mvindex(mydata,0),"%m.%d.%Y")
| eval Event=mvindex(mydata,1)
| eval Host="test"
| table _time Event Host
| rename COMMENT as "The above enters your test data. We've added a key (Host) in case you have multiple sets of data at one time"

| rename COMMENT as "Mark the events we care about"
| eval checkme=case(Event="A",Event, Event="B",Event)

| rename COMMENT as "Copy the related values forward, only on the records we care about."
| streamstats current=f last(checkme) as lastcheck by Host

| rename COMMENT as "If the values exist and have changed, flag the event."
| eval flagme=case(lastcheck!=checkme,"Y")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That's it.  Replace &lt;CODE&gt;by Host&lt;/CODE&gt; with the keys you care about, or eliminate it completely if you  only need to process one set of transactions at a time.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 17:51:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-a-way-to-detect-a-particular-series-of-consecutive/m-p/388083#M113168</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-09-21T17:51:32Z</dc:date>
    </item>
  </channel>
</rss>

