<?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: Comparing two consecutive events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-consecutive-events/m-p/271230#M176789</link>
    <description>&lt;P&gt;I'm assuming you have the name of the process extracted into a &lt;CODE&gt;process&lt;/CODE&gt; field, and that there are no overlapping instances of any one process.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=myIndex sourcetype=applogs process=* (Started OR Completed OR Terminated)
| transaction process startswith=Started endswith=(Completed OR Terminated)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Mild disclaimer: Didn't test if the endswith condition is correct syntax, see &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/Transaction"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/Transaction&lt;/A&gt; to make it work for your specific events.&lt;/P&gt;

&lt;P&gt;That will stitch together the start and end events, and give you a &lt;CODE&gt;duration&lt;/CODE&gt; field per process run. By examining the events for "Completed" or "Terminated" you can tell if the run was successful or not.&lt;/P&gt;

&lt;P&gt;If the assumption of "no overlapping runs" does not hold you need unique IDs to link each start and end event together, and run the &lt;CODE&gt;transaction&lt;/CODE&gt; command on that ID field.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Sep 2016 12:42:06 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2016-09-09T12:42:06Z</dc:date>
    <item>
      <title>Comparing two consecutive events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-consecutive-events/m-p/271229#M176788</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I am trying to evaluate my process using two consecutive events and know whether my process succeeded or failed. My log is set up as below:&lt;BR /&gt;
 1. When process is started, I get - #Timestamp# Started MyProcess &lt;BR /&gt;
 2. When process is completed successfully, I get - #Timestamp# Completed MyProcess &lt;BR /&gt;
 3. If it fails, I get - #Timestamp# Terminated MyProcess&lt;/P&gt;

&lt;P&gt;The process usually  takes a minute or so. I would like to query and find out whether the process has succeeded or failed and also, how long it took. For the immediate (my process runs many times in a day and so I need to compare only the immediate/ consecutive entries) combination of Started and Completed, the status should be success, whereas for Started and Terminated, the status should be Failed.&lt;/P&gt;

&lt;P&gt;My base query is like:&lt;BR /&gt;
index=myIndex sourcetype = applogs "Started MyProcess " Or "Completed MyProcess" Or "Terminated MyProcess"&lt;/P&gt;

&lt;P&gt;Any help would be highly appreciated! Thanks much!&lt;/P&gt;

&lt;P&gt;Cheers!&lt;/P&gt;

&lt;P&gt;PS&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 10:59:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-consecutive-events/m-p/271229#M176788</guid>
      <dc:creator>Parse</dc:creator>
      <dc:date>2016-09-09T10:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing two consecutive events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-two-consecutive-events/m-p/271230#M176789</link>
      <description>&lt;P&gt;I'm assuming you have the name of the process extracted into a &lt;CODE&gt;process&lt;/CODE&gt; field, and that there are no overlapping instances of any one process.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=myIndex sourcetype=applogs process=* (Started OR Completed OR Terminated)
| transaction process startswith=Started endswith=(Completed OR Terminated)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Mild disclaimer: Didn't test if the endswith condition is correct syntax, see &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/Transaction"&gt;http://docs.splunk.com/Documentation/Splunk/6.4.3/SearchReference/Transaction&lt;/A&gt; to make it work for your specific events.&lt;/P&gt;

&lt;P&gt;That will stitch together the start and end events, and give you a &lt;CODE&gt;duration&lt;/CODE&gt; field per process run. By examining the events for "Completed" or "Terminated" you can tell if the run was successful or not.&lt;/P&gt;

&lt;P&gt;If the assumption of "no overlapping runs" does not hold you need unique IDs to link each start and end event together, and run the &lt;CODE&gt;transaction&lt;/CODE&gt; command on that ID field.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 12:42:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-two-consecutive-events/m-p/271230#M176789</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2016-09-09T12:42:06Z</dc:date>
    </item>
  </channel>
</rss>

