<?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: Search result based on max(field) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134544#M36772</link>
    <description>&lt;P&gt;The search should be&lt;/P&gt;

&lt;P&gt;my rex |sort 0 - ResponseTime |stats count,max(ResponseTime) ,first(RequestTime),first(TransactionId) by ServiceName&lt;/P&gt;

&lt;P&gt;If your search returns more than 10,000 results then add | sort 0 field&lt;BR /&gt;
sort command will truncate the output to 10000 rows. &lt;BR /&gt;
results will be automatically limited to 10000 if you don't specify&lt;/P&gt;

&lt;P&gt;| sort 0 field&lt;/P&gt;</description>
    <pubDate>Wed, 09 Jul 2014 06:13:21 GMT</pubDate>
    <dc:creator>th1agarajan</dc:creator>
    <dc:date>2014-07-09T06:13:21Z</dc:date>
    <item>
      <title>Search result based on max(field)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134541#M36769</link>
      <description>&lt;P&gt;Log format&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;ServiceName,ResponseTime,RequestTime,TransactionId&lt;/STRONG&gt;&lt;BR /&gt;
Service1,10,12,12345&lt;BR /&gt;
Service2,5,8,12346&lt;BR /&gt;
Service2,7,3,12347&lt;BR /&gt;
Service1,8,25,12348&lt;BR /&gt;
Service3,5,4,12349&lt;BR /&gt;
Service2,10,2,12350&lt;/P&gt;

&lt;P&gt;&lt;B&gt;Expected result&lt;/B&gt;&lt;/P&gt;

&lt;TABLE border="1"&gt;
&lt;TBODY&gt;&lt;TR&gt;&lt;TH&gt;Service Name&lt;/TH&gt;&lt;TH&gt;Count&lt;/TH&gt;&lt;TH&gt;Max(ResponseTime)&lt;/TH&gt;&lt;TH&gt;RequestTime&lt;/TH&gt;&lt;TH&gt;TransactionId&lt;/TH&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;Service1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;12345&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;Service2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;12350&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;&lt;TD&gt;Service3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;12349&lt;/TD&gt;&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;
I am able to get the service name,count and ResponseTime using the below search. But i need RequestTime and TransactionId based on  Max(ResponseTIme). I need the RequestTime and TransactionId of the record which has Max(ResponseTime). Do i really need sub search to get the desired results?&lt;/P&gt;

&lt;P&gt;my rex | stats count,max(ResponseTime) by ServiceName&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 04:36:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134541#M36769</guid>
      <dc:creator>th1agarajan</dc:creator>
      <dc:date>2014-07-09T04:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Search result based on max(field)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134542#M36770</link>
      <description>&lt;P&gt;Why do not you try to sort?&lt;/P&gt;

&lt;P&gt;my rex |sort ServiceName,- ResponseTime |stats count,max(ResponseTime) ,first(RequestTime),first(TransactionId) by ServiceName&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 05:11:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134542#M36770</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2014-07-09T05:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Search result based on max(field)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134543#M36771</link>
      <description>&lt;P&gt;This is exactly i was looking for. Thank you very much HiroshiSatoh.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 05:28:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134543#M36771</guid>
      <dc:creator>th1agarajan</dc:creator>
      <dc:date>2014-07-09T05:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Search result based on max(field)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134544#M36772</link>
      <description>&lt;P&gt;The search should be&lt;/P&gt;

&lt;P&gt;my rex |sort 0 - ResponseTime |stats count,max(ResponseTime) ,first(RequestTime),first(TransactionId) by ServiceName&lt;/P&gt;

&lt;P&gt;If your search returns more than 10,000 results then add | sort 0 field&lt;BR /&gt;
sort command will truncate the output to 10000 rows. &lt;BR /&gt;
results will be automatically limited to 10000 if you don't specify&lt;/P&gt;

&lt;P&gt;| sort 0 field&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2014 06:13:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-result-based-on-max-field/m-p/134544#M36772</guid>
      <dc:creator>th1agarajan</dc:creator>
      <dc:date>2014-07-09T06:13:21Z</dc:date>
    </item>
  </channel>
</rss>

