<?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 Sorting Duration and Getting the Top 10 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Sorting-Duration-and-Getting-the-Top-10/m-p/112132#M183718</link>
    <description>&lt;P&gt;I have a duration field in seconds.  I wanted the format to be D+hh:mm:ss, so I used this:&lt;BR /&gt;
eval dur_hhmmss=tostring(Duration,"duration") &lt;/P&gt;

&lt;P&gt;Then I had to sort it to get the top 10, so I used the sort then head 10:&lt;BR /&gt;
eval dur_hhmmss=tostring(Duration,"duration")| search dur_hhmmss="*" | chart latest(dur_hhmmss) as Duration by JOBNAME | sort Duration desc | head 10&lt;/P&gt;

&lt;P&gt;I was expecting to see 1+18:36:16 (1+ is 1 DAY), at the top of the list but it's not getting displayed in the top 10 result set.  If I remove head 10, which then would show all the result, I see 1+18:36:16 at the 19th spot, together with those 1hr results.&lt;/P&gt;

&lt;P&gt;How do I get it to appear at the top 10 list?  It looks like Splunk is seeing it as 1hr*&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 15:03:13 GMT</pubDate>
    <dc:creator>splunknovice201</dc:creator>
    <dc:date>2020-09-28T15:03:13Z</dc:date>
    <item>
      <title>Sorting Duration and Getting the Top 10</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-Duration-and-Getting-the-Top-10/m-p/112132#M183718</link>
      <description>&lt;P&gt;I have a duration field in seconds.  I wanted the format to be D+hh:mm:ss, so I used this:&lt;BR /&gt;
eval dur_hhmmss=tostring(Duration,"duration") &lt;/P&gt;

&lt;P&gt;Then I had to sort it to get the top 10, so I used the sort then head 10:&lt;BR /&gt;
eval dur_hhmmss=tostring(Duration,"duration")| search dur_hhmmss="*" | chart latest(dur_hhmmss) as Duration by JOBNAME | sort Duration desc | head 10&lt;/P&gt;

&lt;P&gt;I was expecting to see 1+18:36:16 (1+ is 1 DAY), at the top of the list but it's not getting displayed in the top 10 result set.  If I remove head 10, which then would show all the result, I see 1+18:36:16 at the 19th spot, together with those 1hr results.&lt;/P&gt;

&lt;P&gt;How do I get it to appear at the top 10 list?  It looks like Splunk is seeing it as 1hr*&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:03:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-Duration-and-Getting-the-Top-10/m-p/112132#M183718</guid>
      <dc:creator>splunknovice201</dc:creator>
      <dc:date>2020-09-28T15:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Duration and Getting the Top 10</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-Duration-and-Getting-the-Top-10/m-p/112133#M183719</link>
      <description>&lt;P&gt;The reason it's not working for you is because you have just turned the Duration into a string, and it will now sort alphabetically&lt;/P&gt;

&lt;P&gt;Try this:&lt;/P&gt;

&lt;P&gt;... | search dur_hhmmss="*" | chart latest(Duration) as Duration by JOBNAME | top limit=10 Duration | eval dur_hhmmss=tostring(Duration,"duration") &lt;/P&gt;

&lt;P&gt;Basically you are doing all the calculations you want to do on the Duration while it's a number (integer), and then performing the transform to string at the end.&lt;/P&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:03:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-Duration-and-Getting-the-Top-10/m-p/112133#M183719</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2020-09-28T15:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Duration and Getting the Top 10</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Sorting-Duration-and-Getting-the-Top-10/m-p/112134#M183720</link>
      <description>&lt;P&gt;It worked, thank you!!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2013 19:53:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Sorting-Duration-and-Getting-the-Top-10/m-p/112134#M183720</guid>
      <dc:creator>splunknovice201</dc:creator>
      <dc:date>2013-10-23T19:53:45Z</dc:date>
    </item>
  </channel>
</rss>

