<?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 search the top 5 entries within a transaction by duration? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180857#M52120</link>
    <description>&lt;P&gt;Good ideas... However, 'duration' seems to vanish after the sort operation. In any case, the transaction statement only calculates the duration for the Sections, and its desired to have it by Component, and use that for the top 5 rankings within Section.&lt;BR /&gt;
Perhaps I need to calculate the duration of every line (Component) first and then proceed to the Section calculations.&lt;BR /&gt;
Is 'transaction' the best way to calculate duration of each log entry, given that they are sequential in timestamp?&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;V&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Mon, 29 Jun 2015 17:27:27 GMT</pubDate>
    <dc:creator>vman_me</dc:creator>
    <dc:date>2015-06-29T17:27:27Z</dc:date>
    <item>
      <title>How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180850#M52113</link>
      <description>&lt;P&gt;I am trying to find the top 5 events within a transaction by duration.&lt;BR /&gt;
The transactions are marked by "found section" and "After render" and I need to determine the top 5 events within each section by their duration. The sections might encompass several transactions with similar events in the middle called Components.&lt;/P&gt;

&lt;P&gt;Here is my current search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search | transaction startswith="found section" endswith="After render_to_response"  | top 5 Components by Section
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which needs more work...&lt;BR /&gt;
I am very new to Splunk, any pointers appreciated,&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;V&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 26 Jun 2015 19:15:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180850#M52113</guid>
      <dc:creator>vman_me</dc:creator>
      <dc:date>2015-06-26T19:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180851#M52114</link>
      <description>&lt;P&gt;I think this will do it, but please comment if the mvexpand doesn't work...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search 
| transaction Section startswith="found section" endswith="After render_to_response"  
| table Section Components
| mvexpand Components
| top 5 Components by Section
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also, I think you should be using the Section field in the transaction command, but I could be wrong about that.&lt;/P&gt;

&lt;P&gt;If you have 20 different sections, this will give you 20 "top fives" - one for each section. If you want just one Top 5, perhaps one of these variations on the top command will give you what you want. Try them to see the differences.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| top 5 Components Section

| top 5 Section Components

| top 5 Components
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Jun 2015 19:53:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180851#M52114</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-06-26T19:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180852#M52115</link>
      <description>&lt;P&gt;Good stuff,  Its close... but I'd like top 5 in time duration, not in count... &lt;/P&gt;

&lt;P&gt;I guess it would be like considering every log within a Section as a transaction itself and then determine duration and rank it by top 5 per Section.&lt;/P&gt;

&lt;P&gt;Also, i get '1' for the count of the first Section components and I can see there are more than 1...  distributed across the Section transactions&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
- V&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 21:28:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180852#M52115</guid>
      <dc:creator>vman_me</dc:creator>
      <dc:date>2015-06-26T21:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180853#M52116</link>
      <description>&lt;P&gt;I guess the (time) duration needs to be calculated from the previous timestamp and the current one. They are sequential log messages.&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
 - V&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 22:15:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180853#M52116</guid>
      <dc:creator>vman_me</dc:creator>
      <dc:date>2015-06-26T22:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180854#M52117</link>
      <description>&lt;P&gt;Thanks for the explanation about the time - could you post a couple of sample events? (with identifying information edited, of course)&lt;/P&gt;

&lt;P&gt;I am thinking about how to answer this using time duration instead of count.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 22:38:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180854#M52117</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-06-26T22:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180855#M52118</link>
      <description>&lt;P&gt;Nothing special to these logs. The format is more or less like this&lt;/P&gt;

&lt;P&gt;timestamp IPaddr Component&lt;/P&gt;

&lt;P&gt;In reality "found section" and "After render" are the first two words of Component, a text description.&lt;BR /&gt;
I could tweak the format if that could help for the end goal,&lt;BR /&gt;
The transaction operation works well in grouping the section, now just need to get the duration for each intermediary log event, all in sequence through the timestamp. Then find the top 5 for each Section. Each Section group appears in different parts of the stream (so their component durations would be need to be aggregated before picking top 5 of each Section) &lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
 - V&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jun 2015 22:57:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180855#M52118</guid>
      <dc:creator>vman_me</dc:creator>
      <dc:date>2015-06-26T22:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180856#M52119</link>
      <description>&lt;P&gt;try like :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search gro | transaction Section startswith="found section" endswith="After render_to_response" |stats sum(duration) as duration list(Components) as Components by Section |sort -duration| table Section Components duration | head 5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2015 12:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180856#M52119</guid>
      <dc:creator>fdi01</dc:creator>
      <dc:date>2015-06-29T12:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180857#M52120</link>
      <description>&lt;P&gt;Good ideas... However, 'duration' seems to vanish after the sort operation. In any case, the transaction statement only calculates the duration for the Sections, and its desired to have it by Component, and use that for the top 5 rankings within Section.&lt;BR /&gt;
Perhaps I need to calculate the duration of every line (Component) first and then proceed to the Section calculations.&lt;BR /&gt;
Is 'transaction' the best way to calculate duration of each log entry, given that they are sequential in timestamp?&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;V&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 29 Jun 2015 17:27:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180857#M52120</guid>
      <dc:creator>vman_me</dc:creator>
      <dc:date>2015-06-29T17:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180858#M52121</link>
      <description>&lt;P&gt;So each event (from "found section" to "After render") actually contains the Section field? Are there multiple transactions for a section - in other words, are there multiple sets of "found section" to "After render"?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2015 20:29:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180858#M52121</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-07-01T20:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180859#M52122</link>
      <description>&lt;P&gt;If there is only one "transaction" per Section, then this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
| sort Section _time
| eventstats earliest(_time) as startTime by Section
| eval duration = _time - startTime
| stats sum(duration) as duration by Section Component
| sort Section Component -duration
| stats list(duration) as duration list(Component) as Component by Section
| eval duration=mvindex(duration,0,4)
| eval Component=mvindex(Component,0,4)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;First, this establishes the starting time for each section and names it "startTime." The duration of each component is computed from this startTime. Next, the results are sorted so that the highest durations appear first in the list. Then the results are grouped and the mvindex command is used to "pick out" the first 5 results for each section.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2015 20:46:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180859#M52122</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2015-07-01T20:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180860#M52123</link>
      <description>&lt;P&gt;Good stuff...&lt;BR /&gt;
There is more that one transaction (Component) per Section and I am able to compute the duration by using "window=1" on streamstats after sorting by time as well. However, I did try your solution and it seems to work well, but for some reason only get 3 sections (lexicographically)  not sure why. Any idea?&lt;BR /&gt;
(More interesting would be to pick the top 3 Sections by time as well...)&lt;BR /&gt;
Thanks,&lt;BR /&gt;
 - V&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jul 2015 22:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180860#M52123</guid>
      <dc:creator>vman_me</dc:creator>
      <dc:date>2015-07-01T22:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180861#M52124</link>
      <description>&lt;P&gt;Ok it looks good... just changed the  sorting order in last sort to:&lt;BR /&gt;
sort Section -duration Component&lt;BR /&gt;
and i do get all sections... &lt;BR /&gt;
Just need to pick the top 3 Sections now...&lt;BR /&gt;&lt;BR /&gt;
This can be fun &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
Cheers, - V&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jul 2015 00:48:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180861#M52124</guid>
      <dc:creator>vman_me</dc:creator>
      <dc:date>2015-07-02T00:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to search the top 5 entries within a transaction by duration?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180862#M52125</link>
      <description>&lt;P&gt;Ok, I added a duration per Section and then tried to sort by that field:&lt;/P&gt;

&lt;P&gt;... | sort -sduration  Section -duration Component  |.. &lt;/P&gt;

&lt;P&gt;which seems to work fine for the Section and its duration but the Component part doesnt get sorted...&lt;BR /&gt;&lt;BR /&gt;
Do I need to change drastically the solution or is there something to sort the Component subtable?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;
 - V&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jul 2015 00:46:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-the-top-5-entries-within-a-transaction-by-duration/m-p/180862#M52125</guid>
      <dc:creator>vman_me</dc:creator>
      <dc:date>2015-07-03T00:46:37Z</dc:date>
    </item>
  </channel>
</rss>

