<?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: If there are multiple events that start a transaction, how to write a transaction search to find the earliest one? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173527#M49776</link>
    <description>&lt;P&gt;Thank you for your reply Martin perhaps I oversimplified the example here in that the first transaction had a sing start event and the second had two identical start event.  The reality is that I have many transactions and each transaction can have one, two or many start events.  Tried your suggestion but it did not help.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Oct 2014 19:50:53 GMT</pubDate>
    <dc:creator>czervos</dc:creator>
    <dc:date>2014-10-29T19:50:53Z</dc:date>
    <item>
      <title>If there are multiple events that start a transaction, how to write a transaction search to find the earliest one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173525#M49774</link>
      <description>&lt;P&gt;Let's say I have a log that containts&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;starttranscation&lt;/LI&gt;
&lt;LI&gt;some other events&lt;/LI&gt;
&lt;LI&gt;end transaction&lt;/LI&gt;
&lt;LI&gt;some other events&lt;/LI&gt;
&lt;LI&gt;starttransaction&lt;/LI&gt;
&lt;LI&gt;starttransaction &amp;lt;--- note this is not a typo it is indeed a legit second starttransaction event &lt;/LI&gt;
&lt;LI&gt;some other events&lt;/LI&gt;
&lt;LI&gt;end transaction&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;We want for the first transaction to be delineated by event 1 to 3 and the second transaction to be delineated by event 5 to 8.&lt;/P&gt;

&lt;P&gt;If we use (transaction startswith="starttransaction" endswith="end transaction" my second transaction is delineated by events 6 to 8 instead of 5-8. As a result the duration is shorter than what expected.  In other words the starttransaction event proceeding the end transaction event is always being picked whereas we would like for the first "starttransaction" following the end transaction to be picked.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Oct 2014 17:55:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173525#M49774</guid>
      <dc:creator>czervos</dc:creator>
      <dc:date>2014-10-21T17:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: If there are multiple events that start a transaction, how to write a transaction search to find the earliest one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173526#M49775</link>
      <description>&lt;P&gt;I believe this search illustrates your question:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval event = "end start start" | makemv event | mvexpand event | streamstats count | eval _time = now() - count | transaction startswith="event=start" endswith="event=end" keepevicted=t
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Returns one two-event transaction and one left over "start" event.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Oct 2014 20:04:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173526#M49775</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-21T20:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: If there are multiple events that start a transaction, how to write a transaction search to find the earliest one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173527#M49776</link>
      <description>&lt;P&gt;Thank you for your reply Martin perhaps I oversimplified the example here in that the first transaction had a sing start event and the second had two identical start event.  The reality is that I have many transactions and each transaction can have one, two or many start events.  Tried your suggestion but it did not help.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Oct 2014 19:50:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173527#M49776</guid>
      <dc:creator>czervos</dc:creator>
      <dc:date>2014-10-29T19:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: If there are multiple events that start a transaction, how to write a transaction search to find the earliest one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173528#M49777</link>
      <description>&lt;P&gt;I think you can do this using &lt;CODE&gt;streamstats&lt;/CODE&gt; to count each occurrence of your starting events, using &lt;CODE&gt;eventstats&lt;/CODE&gt; to find the starting event with the highest count (i.e., the oldest one), and then include that count as a criteria for &lt;CODE&gt;startswith&lt;/CODE&gt;.  &lt;/P&gt;

&lt;P&gt;For my example search, assume that &lt;CODE&gt;gField&lt;/CODE&gt; is the field that contains the common element between your events (like a transaction number, session id, or something like that), and that &lt;CODE&gt;sField&lt;/CODE&gt; is a field that you use in your &lt;CODE&gt;startswith&lt;/CODE&gt; criteria &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your base search ... | streamstats count by gField sField | eventstats max(count) as sFieldMax by sField | transaction gField startswith="sField=&amp;lt;starting value&amp;gt; count=sFieldOrder" endswith="sField=&amp;lt;ending value&amp;gt;" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Modifying the illustration by @martin_mueller the search would look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval event = "end start start" | makemv event | mvexpand event | eval sField=1 | streamstats count | eval _time = now() - count | eventstats max(count) as mCount by sField | transaction startswith="event=start sField=mCount" endswith="event=end" keepevicted=t
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Someone else out there may have a more streamlined approach, but this should do the trick for you.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Oct 2014 20:49:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173528#M49777</guid>
      <dc:creator>wpreston</dc:creator>
      <dc:date>2014-10-29T20:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: If there are multiple events that start a transaction, how to write a transaction search to find the earliest one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173529#M49778</link>
      <description>&lt;P&gt;Thank you Martin, unfortuantely I do not have a common element between the events in my transactions.  I am trying to measure how long it takes for wpa_supplicant to connect to an AP after it starts scanning.  Often it scans for more than once before it connects and as a result many scan-started events are recorded. My reduced data set is something like this&lt;/P&gt;

&lt;P&gt;1412026262.159449: wlan2: CTRL-EVENT-SCAN-STARTED   &amp;lt;---- start of transaction 1&lt;BR /&gt;
1412026258.783734: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026226.229726: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026211.712098: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026203.900786: wlan2: CTRL-EVENT-CONNECTED - Connection to e8:ed:f3:10:cd:3f completed [id=0 id_str=] &amp;lt;--- end of transaction 1&lt;BR /&gt;
1412026188.747661: wlan2: CTRL-EVENT-SCAN-STARTED   &amp;lt;---- start of transaction 2&lt;BR /&gt;
1412026177.658687: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026147.650857: wlan2: CTRL-EVENT-CONNECTED - Connection to e8:ed:f3:10:51:2f completed [id=0 id_str=] &amp;lt;--- end of transaction 2&lt;BR /&gt;
1412026146.463960: wlan2: CTRL-EVENT-SCAN-STARTED  &amp;lt;---- start of transaction 3&lt;BR /&gt;
1412026143.323471: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026131.259936: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026125.254478: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026110.808932: wlan2: CTRL-EVENT-CONNECTED - Connection to e8:ed:f3:10:6e:ff completed [id=0 id_str=] &amp;lt;--- end of transaction 3&lt;BR /&gt;
1412026109.575031: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026105.132968: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026089.933802: wlan2: CTRL-EVENT-CONNECTED - Connection to f8:4f:57:66:53:9f completed [id=0 id_str=]&lt;BR /&gt;
1412026087.472444: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026073.058930: wlan2: CTRL-EVENT-SCAN-STARTED &lt;BR /&gt;
1412026050.153576: wlan2: CTRL-EVENT-CONNECTED - Connection to e8:ed:f3:10:cd:3f completed [id=0 id_str=]&lt;/P&gt;

&lt;P&gt;As you see more often than not there are more than one scans before the supplicant connects (the transaction ends)&lt;/P&gt;

&lt;P&gt;If I make my transaction to be&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;| transaction startswith="CTRL-EVENT-SCAN-STARTED"  endswith="CTRL-EVENT-CONNECTED"&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;then instead of picking the first scan-started event in each transaction it picks up the last scan-started in each transaction and as a result duration of my transactions is much shorter than what I really am interested in measuring.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:58:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173529#M49778</guid>
      <dc:creator>czervos</dc:creator>
      <dc:date>2020-09-28T17:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: If there are multiple events that start a transaction, how to write a transaction search to find the earliest one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173530#M49779</link>
      <description>&lt;P&gt;thanks wpreston!&lt;/P&gt;

&lt;P&gt;This works! perhaps a flag to consider the earliest startswith event as feature enhancement might be good..&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2016 13:19:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173530#M49779</guid>
      <dc:creator>stanwin</dc:creator>
      <dc:date>2016-08-01T13:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: If there are multiple events that start a transaction, how to write a transaction search to find the earliest one?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173531#M49780</link>
      <description>&lt;P&gt;Where did sFieldOrder came from? (in the first example) &lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 15:45:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-there-are-multiple-events-that-start-a-transaction-how-to/m-p/173531#M49780</guid>
      <dc:creator>ohmyguigs</dc:creator>
      <dc:date>2017-03-06T15:45:46Z</dc:date>
    </item>
  </channel>
</rss>

