<?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: Grouping by numeric range in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27500#M5340</link>
    <description>&lt;P&gt;It's a little complicated, but the following search should produce a result similar to what you described:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your search ... | eval responseTime=responseTime/1000 | sort responseTime | eventstats count as total | eval in_range=round(case(responseTime&amp;lt;5, floor(2*responseTime)/2+.5, responseTime&amp;lt;10,ceil(responseTime), responseTime&amp;gt;10,100000.0),1) | streamstats count as cnt avg(responseTime) as run_avg | stats first(total) as total last(run_avg) as run_avg max(cnt) as count count as cnt by in_range | sort in_range | eval range=if(in_range&amp;gt;10, "&amp;gt;= 10.0 sec","&amp;lt; "+tostring(in_range)+" sec") | eval pct=round(count/total*100,2) | eval run_avg=round(run_avg,2) | rename cnt as "No of Transactions" pct as "Cum. response %" run_avg as "Running Avg" | table range "Cum. response %" "Running Avg" "No of Transactions"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Apr 2012 14:14:28 GMT</pubDate>
    <dc:creator>ziegfried</dc:creator>
    <dc:date>2012-04-16T14:14:28Z</dc:date>
    <item>
      <title>Grouping by numeric range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27498#M5338</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Novice to Splunk, I've indexed some data and now want to perform some reports on it.&lt;/P&gt;

&lt;P&gt;My main requirement is that I need to get stats on response times as follows by grouping them by how long they took. The report would look similar to the following:&lt;/P&gt;

&lt;TABLE border="1"&gt;
&lt;TBODY&gt;&lt;TR&gt;
&lt;TD&gt;&lt;/TD&gt;
&lt;TD align="center"&gt;Cum. response %&lt;/TD&gt;
&lt;TD&gt;Running Avg&lt;/TD&gt;
&lt;TD&gt;No of Transactions&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;lt;0.5 sec&lt;/TD&gt;
&lt;TD align="center"&gt;55.89&lt;/TD&gt;
&lt;TD align="center"&gt;0.31&lt;/TD&gt;
&lt;TD align="center"&gt;268,676&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;lt;1.0 sec&lt;/TD&gt;
&lt;TD align="center"&gt;96.58&lt;/TD&gt;
&lt;TD align="center"&gt;0.45&lt;/TD&gt;
&lt;TD align="center"&gt;195,582&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;lt;1.5 sec&lt;/TD&gt;
&lt;TD align="center"&gt;98.98&lt;/TD&gt;
&lt;TD align="center"&gt;0.47&lt;/TD&gt;
&lt;TD align="center"&gt;11,578&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;lt;2.0 sec&lt;/TD&gt;
&lt;TD align="center"&gt;99.39&lt;/TD&gt;
&lt;TD align="center"&gt;0.47&lt;/TD&gt;
&lt;TD align="center"&gt;1,976&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;I need to group in .5 second intervals up to 5 seconds and then 1 second intervals after that up to 10 seconds, with the final row being for everything over 10 seconds. Thie field being grouped on is a numeric field that holds the number of milliseconds for the response time.&lt;/P&gt;

&lt;P&gt;Being new to Splunk, I have no idea about how to do the grouping, so I would be grateful for suggestions.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;/P&gt;

&lt;P&gt;Rob&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 12:29:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27498#M5338</guid>
      <dc:creator>bermudabob</dc:creator>
      <dc:date>2012-04-16T12:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by numeric range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27499#M5339</link>
      <description>&lt;P&gt;You can use the rangemap function and then do a stats grouping by the range.  Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rangemap field=responseTime "&amp;lt;0.5"=0-50 "&amp;lt;1"=0-100 "&amp;lt;1.5"=0-150 "&amp;lt;2.0"=0-200 | stats sum(responseTime) as "Cum Response Time", avg(responseTime) as "Running Avg", count as "Number of Transactions" by range
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Apr 2012 13:14:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27499#M5339</guid>
      <dc:creator>ayme</dc:creator>
      <dc:date>2012-04-16T13:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by numeric range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27500#M5340</link>
      <description>&lt;P&gt;It's a little complicated, but the following search should produce a result similar to what you described:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... your search ... | eval responseTime=responseTime/1000 | sort responseTime | eventstats count as total | eval in_range=round(case(responseTime&amp;lt;5, floor(2*responseTime)/2+.5, responseTime&amp;lt;10,ceil(responseTime), responseTime&amp;gt;10,100000.0),1) | streamstats count as cnt avg(responseTime) as run_avg | stats first(total) as total last(run_avg) as run_avg max(cnt) as count count as cnt by in_range | sort in_range | eval range=if(in_range&amp;gt;10, "&amp;gt;= 10.0 sec","&amp;lt; "+tostring(in_range)+" sec") | eval pct=round(count/total*100,2) | eval run_avg=round(run_avg,2) | rename cnt as "No of Transactions" pct as "Cum. response %" run_avg as "Running Avg" | table range "Cum. response %" "Running Avg" "No of Transactions"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Apr 2012 14:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27500#M5340</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-04-16T14:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by numeric range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27501#M5341</link>
      <description>&lt;P&gt;The answer provided by ayme certainly works and is probably what you want. If you have a lot of ranges, you could save yourself some typing by using &lt;CODE&gt;eval&lt;/CODE&gt; to create a field to group by. However, in this case rangemap is probably quicker and easier for you.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval rt_group=if(responseTime&amp;gt;10000, "&amp;gt; 10.0 sec","&amp;lt; ". if(responseTime&amp;gt;5000, round(ceil(responseTime/1000),1) ,round(ceil(responseTime/500)*500/1000,1)) . " sec") | stats sum(responseTime), avg(responseTime), count by rt_group
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Apr 2012 14:22:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27501#M5341</guid>
      <dc:creator>echalex</dc:creator>
      <dc:date>2012-04-16T14:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by numeric range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27502#M5342</link>
      <description>&lt;P&gt;I don't think you can calculate the cumulative percentage and a running average this way...&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 14:32:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27502#M5342</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-04-16T14:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by numeric range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27503#M5343</link>
      <description>&lt;P&gt;Thanks for that - just what I need for the grouping. I'm still trying to figure out how to do the cumulative percentage column, I thought it was something to do with streamstats, but can't seem to get it to work...&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 14:35:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27503#M5343</guid>
      <dc:creator>bermudabob</dc:creator>
      <dc:date>2012-04-16T14:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by numeric range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27504#M5344</link>
      <description>&lt;P&gt;This one seems to work (although I don't understand how! I'm not good at this yet...) Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 14:59:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27504#M5344</guid>
      <dc:creator>bermudabob</dc:creator>
      <dc:date>2012-04-16T14:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping by numeric range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27505#M5345</link>
      <description>&lt;P&gt;I'll add an explanation later&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 15:12:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Grouping-by-numeric-range/m-p/27505#M5345</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2012-04-16T15:12:20Z</dc:date>
    </item>
  </channel>
</rss>

