<?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 Capturing the final value from the final event in a transaction? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60906#M14991</link>
    <description>&lt;P&gt;I have created a transaction that may contain one or more of these three log level types logLevels i.e. METRIC/INFO/WARN&lt;/P&gt;

&lt;P&gt;For Example: Assume that one transaction holds three events, each event has its own logLevel type.&lt;/P&gt;

&lt;P&gt;My Question is, How Can I pick up the final LogLevel type  for the last event at the end of a Transaction?&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2012 06:48:57 GMT</pubDate>
    <dc:creator>Dark_Ichigo</dc:creator>
    <dc:date>2012-01-31T06:48:57Z</dc:date>
    <item>
      <title>Capturing the final value from the final event in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60906#M14991</link>
      <description>&lt;P&gt;I have created a transaction that may contain one or more of these three log level types logLevels i.e. METRIC/INFO/WARN&lt;/P&gt;

&lt;P&gt;For Example: Assume that one transaction holds three events, each event has its own logLevel type.&lt;/P&gt;

&lt;P&gt;My Question is, How Can I pick up the final LogLevel type  for the last event at the end of a Transaction?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2012 06:48:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60906#M14991</guid>
      <dc:creator>Dark_Ichigo</dc:creator>
      <dc:date>2012-01-31T06:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the final value from the final event in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60907#M14992</link>
      <description>&lt;P&gt;You should be able to use &lt;CODE&gt;stats&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats last(LogLevel) by _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jan 2012 08:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60907#M14992</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-01-31T08:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the final value from the final event in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60908#M14993</link>
      <description>&lt;P&gt;It depends if those different LogLevel fields can happen in one transaction multiple times or not.&lt;/P&gt;

&lt;P&gt;It gets a bit more tricky if you can have multiple LogLevel fields in one transaction, i.e. like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;INFO
WARN
INFO
WARN
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And you want to know what the last one was. In such cases I usually use the following trick:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | eval temp1=_time+","+LogLevel | transaction something | eval LastLogLevel=substr(mvindex(temp1,mvcount(temp1)-1),16)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will create a new field that contains concatenated timestamp and the LogLevel field. One such field will be created for every LogLevel appearance in your transaction so you simply pick the last one with the mvindex command and pull out the value with substr.&lt;BR /&gt;
There might be a more efficient way to do this too &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2012 22:01:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60908#M14993</guid>
      <dc:creator>bojanz</dc:creator>
      <dc:date>2012-01-31T22:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the final value from the final event in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60909#M14994</link>
      <description>&lt;P&gt;As bojanz says, it depends on whether multiple log levels appear in a transaction. It also depends on whether you have used the Splunk transaction command to create the "transaction" that you mention, or if you are referring to the transactions that logically exist in your events.&lt;/P&gt;

&lt;P&gt;Using the "transaction" command in Splunk is very cool, but also expensive. So if you don't need the resulting transaction for any other reason, try something like this instead&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | stats latest(logLevel) by transactionId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will return the latest (in time) logLevel in a transaction.  If you have multiple criteria that define a transaction, you could use them all here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | stats latest(logLevel) by customerId, sessionId
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This would return one logLevel for each combination of customerId and sessionId&lt;/P&gt;

&lt;P&gt;The above will return the latest logLevel, whatever it is, regardless of whether there are multiple logLevels in the transaction.&lt;/P&gt;

&lt;P&gt;Oh, and if you want to return the last logLevel for each unique logLevel that appears in the transaction, as bojanz did, just add logLevel to the by clause:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;mysearch | stats latest(logLevel) by transactionId, logLevel
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2012 22:27:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60909#M14994</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-02-01T22:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the final value from the final event in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60910#M14995</link>
      <description>&lt;P&gt;Bingo!.....Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2012 05:58:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60910#M14995</guid>
      <dc:creator>Dark_Ichigo</dc:creator>
      <dc:date>2012-02-10T05:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Capturing the final value from the final event in a transaction?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60911#M14996</link>
      <description>&lt;P&gt;Works like a charm. Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2015 23:10:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Capturing-the-final-value-from-the-final-event-in-a-transaction/m-p/60911#M14996</guid>
      <dc:creator>ifeldshteyn</dc:creator>
      <dc:date>2015-12-10T23:10:32Z</dc:date>
    </item>
  </channel>
</rss>

