<?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: How to start transaction with the earliest event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346240#M102571</link>
    <description>&lt;P&gt;Provided the &lt;CODE&gt;Message&lt;/CODE&gt; field is extracted, below search should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
| dedup ItemID Message sortby _time
| transaction ItemID startswith="UseCaseX.ProcessData" endswith="CalculateScore" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Aug 2019 04:14:49 GMT</pubDate>
    <dc:creator>jawaharas</dc:creator>
    <dc:date>2019-08-20T04:14:49Z</dc:date>
    <item>
      <title>How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346231#M102562</link>
      <description>&lt;P&gt;I need to document a transaction that begins with a multithreaded process.  The process creates multiple entries in an event log:&lt;/P&gt;

&lt;P&gt;Message: UseCaseX.ProcessData ItemID=5 Provider=123 ElapsedMilliseconds=230 timestamp=09/21/2017 10:16:33 AM &lt;BR /&gt;
Message: UseCaseX.ProcessData ItemID=5 Provider=333 ElapsedMilliseconds=130 timestamp=09/21/2017 10:16:38 AM &lt;BR /&gt;
Message: UseCaseX.ProcessData ItemID=5 Provider=999 ElapsedMilliseconds=780 timestamp=09/21/2017 10:16:41 AM&lt;/P&gt;

&lt;P&gt;The 'Provider' value will vary on every occasion; there's no telling which Provider may come first.&lt;/P&gt;

&lt;P&gt;The transaction ends with a single identifiable event log entry:&lt;BR /&gt;
Message: UseCaseY.CalculateScore ItemID=5 ElapsedMilliseconds=780 timestamp=09/21/2017 10:16:58 AM&lt;/P&gt;

&lt;P&gt;There are many other log entries and servers involved in the time between the beginning of the transaction and UseCaseY.CalculateScore.  I'm trying to produce a transaction that will have its duration span from the &lt;STRONG&gt;first&lt;/STRONG&gt; instance of UseCaseX.ProcessData to the instance of UseCaseY.CalculateScore.  &lt;/P&gt;

&lt;P&gt;searchHere | transaction ItemID startswith="UseCaseX.ProcessData" endswith="CalculateScore"&lt;/P&gt;

&lt;P&gt;I'm getting a duration that starts with "10:16:41 AM", when I want my duration to start with "10:16:33 AM".&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 20:03:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346231#M102562</guid>
      <dc:creator>jasongb</dc:creator>
      <dc:date>2017-09-21T20:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346232#M102563</link>
      <description>&lt;P&gt;@jasongb, Have you tried with stats instead of transaction?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt; ("UseCaseX.ProcessData" OR "UseCaseY.CalculateScore")
| eval transactionType=case(searchmatch("UseCaseX.ProcessData"),"ProcessData",searchmatch("UseCaseY.CalculateScore"),"CalculateScore")
| stats earliest(_time) as earliestTime latest(_time) as latestTime values(transactionType) as transactionType dc(transactionType) as distinctTypes by ItemID
| search distinctTypes=2 transactionType="ProcessData" transactionType="CalculateScore"
| eval duration=latestTime-earliestTime
| eval _time=earliestTime
| fields - latestTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 20:44:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346232#M102563</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-21T20:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346233#M102564</link>
      <description>&lt;P&gt;may be it will work&lt;/P&gt;

&lt;P&gt;search here | reverse | transaction ItemID startswith="UseCaseX.ProcessData" endswith="CalculateScore"&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 20:55:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346233#M102564</guid>
      <dc:creator>sbbadri</dc:creator>
      <dc:date>2017-09-21T20:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346234#M102565</link>
      <description>&lt;P&gt;Thanks very much for your suggestion!  I have been focused on the transaction command because of the other data that's between the start and end of the transaction.  The data spans multiple servers, multiple logs (iis, event log, etc.) and many different types of events.&lt;/P&gt;

&lt;P&gt;Each event can be reliably linked by the ItemID field.  &lt;/P&gt;

&lt;P&gt;I'm under the impression that the stats command might let me produce some elements of what I need (i.e., an accurate duration), but it won't let me harvest all of the events that occur from beginning to end.  The transaction command is meeting all of my needs - except for letting me see the &lt;EM&gt;first&lt;/EM&gt; instance of that 'startswith'.&lt;/P&gt;

&lt;P&gt;I will look further into the stats command; perhaps it's a case of not asking the right question of the data.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 22:03:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346234#M102565</guid>
      <dc:creator>jasongb</dc:creator>
      <dc:date>2017-09-21T22:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346235#M102566</link>
      <description>&lt;P&gt;Thanks for your suggestion!... however, this did not work for me.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 22:04:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346235#M102566</guid>
      <dc:creator>jasongb</dc:creator>
      <dc:date>2017-09-21T22:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346236#M102567</link>
      <description>&lt;P&gt;Do read about event grouping and correlation: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Search/Abouteventcorrelation&lt;/A&gt;. What you seem to be achieveing through transaction, similar results can be fetched via stats which would be way faster. I had missed correlating events by ItemID as in your original transaction which I have updated by adding &lt;CODE&gt;by ItemID&lt;/CODE&gt; in the stats command.&lt;/P&gt;

&lt;P&gt;You can use &lt;CODE&gt;values(&amp;lt;YourFileName&amp;gt;)&lt;/CODE&gt; and &lt;CODE&gt;list(&amp;lt;YourFieldName&amp;gt;)&lt;/CODE&gt; to fetch the required details once correlated via &lt;CODE&gt;ItemID&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Could you please elaborate as to what do you mean by &lt;CODE&gt;won't let me harvest all of the events that occur from beginning to end.&lt;/CODE&gt;? Also what is the remaining part of your search once you have correlated events through the transaction command?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 23:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346236#M102567</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-21T23:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346237#M102568</link>
      <description>&lt;P&gt;searchHere | transaction ItemID startswith="UseCaseX.ProcessData" endswith="CalculateScore" | reverse&lt;BR /&gt;
It will probably work with this.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 02:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346237#M102568</guid>
      <dc:creator>oda</dc:creator>
      <dc:date>2017-09-22T02:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346238#M102569</link>
      <description>&lt;P&gt;Thank you for your suggestion!  This did not work for me.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 18:05:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346238#M102569</guid>
      <dc:creator>jasongb</dc:creator>
      <dc:date>2017-09-22T18:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346239#M102570</link>
      <description>&lt;P&gt;I regret to hear that.&lt;BR /&gt;
In my environment it seems to work with it.&lt;BR /&gt;
Does nothing change even if this command is changed?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 00:36:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346239#M102570</guid>
      <dc:creator>oda</dc:creator>
      <dc:date>2017-09-25T00:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346240#M102571</link>
      <description>&lt;P&gt;Provided the &lt;CODE&gt;Message&lt;/CODE&gt; field is extracted, below search should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;YourBaseSearch&amp;gt;
| dedup ItemID Message sortby _time
| transaction ItemID startswith="UseCaseX.ProcessData" endswith="CalculateScore" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2019 04:14:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346240#M102571</guid>
      <dc:creator>jawaharas</dc:creator>
      <dc:date>2019-08-20T04:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346241#M102572</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults
|eval raw="Message: UseCaseX.ProcessData ItemID=5 Provider=123 ElapsedMilliseconds=230 timestamp=09/21/2017T10:16:33;Message: UseCaseX.ProcessData ItemID=5 Provider=333 ElapsedMilliseconds=130 timestamp=09/21/2017T10:16:38;Message: UseCaseX.ProcessData ItemID=5 Provider=999 ElapsedMilliseconds=780 timestamp=09/21/2017T10:16:41;Message: UseCaseY.CalculateScore ItemID=5 ElapsedMilliseconds=780 timestamp=09/21/2017T10:16:58" 
| makemv delim=";" raw
|mvexpand raw 
| rename raw AS _raw 
`comment("Ignore above code which is just used for generating a dataset")`

| kv 
| eval _time = strptime(timestamp,"%m/%d/%YT%H:%M:%S") 
|rex field=_raw "Message\:\s+(?&amp;lt;Message&amp;gt;.*?)\s*\s+ItemID" 
| dedup ItemID Message
|reverse 
| transaction ItemID startswith="UseCaseX.ProcessData" endswith="CalculateScore"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2019 05:27:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346241#M102572</guid>
      <dc:creator>nareshinsvu</dc:creator>
      <dc:date>2019-08-20T05:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346242#M102573</link>
      <description>&lt;P&gt;@niketnilay  - Would you recommend this approach over transaction if we want to group (say) 10 or more events into a group using a common identifier which is re-used by other group of events? &lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 06:06:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346242#M102573</guid>
      <dc:creator>nareshinsvu</dc:creator>
      <dc:date>2019-08-20T06:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to start transaction with the earliest event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346243#M102574</link>
      <description>&lt;P&gt;@nareshinsvu transaction is usually good when you know the session ID and starting and end conditions. However, the answer would depend on the data you have the output you want and the volume&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 08:40:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-start-transaction-with-the-earliest-event/m-p/346243#M102574</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-08-20T08:40:09Z</dc:date>
    </item>
  </channel>
</rss>

