<?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 Timechart for only the 10 highest counted values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400268#M115976</link>
    <description>&lt;P&gt;I'm leaving this here because it shows a way you could use to build more complex in-or-out behavior, but the simple and elegant answer by @kamlesh_vaghela is the correct one to use.   &lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;You need to do some kind of summary aggregation before the timechart command... in the part of the search you left out... in order to make that happen.  The tool of choice for this is often &lt;CODE&gt;eventstats&lt;/CODE&gt; - which acts like the &lt;CODE&gt;stats&lt;/CODE&gt; command but leaves the underlying events alone, merely adding the results to the underlying events.  Another useful tool is &lt;CODE&gt;appendpipe&lt;/CODE&gt; - which takes all the results, lets you process them in some way, and then adds them back as new events onto the end of the prior results.  And a third useful tool is a subsearch, where you go get certain information and feed that information back as a limit on the outer search.&lt;/P&gt;

&lt;P&gt;Which one of the above constructions performs best will be VERY data dependent.  So, you try each one and stop when you have acceptable performance, or pick the best of the unacceptable performances.  &lt;/P&gt;

&lt;P&gt;Now, you need to define what you mean by "the 10 most common paths".  You could mean the ones that were the 10 most common today, or this month.  you could mean the 10 paths that had the highest AVERAGE use, or the highest PEAK use, or the highest P90 use.  &lt;/P&gt;

&lt;P&gt;I'm going to assume the total count over the period of the search - which amounts to the same as average - for the purposes of these examples.  This first one filters off only the paths you want from your second search..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=... | timechart max(transTime) by path useother=false usenull=false
  | search [ your first search | top 10 by path | table path]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That way will work, but it is eliminating the unneeded paths after doing all the work of calculation.  Better to do it in the other order.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index= ... [ your first search | top 10 by path | table path]...
  ...
| timechart max(transTime) by path useother=false usenull=false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the field &lt;CODE&gt;path&lt;/CODE&gt; is not on the underlying records, then put the &lt;CODE&gt;search [...]&lt;/CODE&gt; as early as you can, in order to cull the records.  &lt;/P&gt;</description>
    <pubDate>Fri, 22 Jun 2018 14:52:45 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2018-06-22T14:52:45Z</dc:date>
    <item>
      <title>How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400266#M115974</link>
      <description>&lt;P&gt;I am monitoring access logs for various endpoints (which I denote as path), and in each event I have some data including how long the event took. I have one timechart that monitors which endpoints get called the most, and I am trying to create a timechart that will monitor the max transaction times, but only for the most called endpoints.&lt;BR /&gt;
The first timechart was very easy:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=... | timechart count by path useother=false usenull=false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The second search has proven more difficult, as this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=... | timechart max(transTime) by path useother=false usenull=false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Only yields the max transaction times regardless of how often the path is called.&lt;BR /&gt;
I have tried using top and head to restrict the available paths, but to no avail. Is there a way to force timechart to use only the 10 most common paths?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 13:53:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400266#M115974</guid>
      <dc:creator>dsitek</dc:creator>
      <dc:date>2018-06-22T13:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400267#M115975</link>
      <description>&lt;P&gt;I believe you could use a subsearch to return just the top 10 paths before you did the timechart&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=...
[ search index=... | stats count by path | top 10 path | fields path]
 | timechart max(transTime) by path useother=false usenull=false
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jun 2018 14:31:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400267#M115975</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-06-22T14:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400268#M115976</link>
      <description>&lt;P&gt;I'm leaving this here because it shows a way you could use to build more complex in-or-out behavior, but the simple and elegant answer by @kamlesh_vaghela is the correct one to use.   &lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;You need to do some kind of summary aggregation before the timechart command... in the part of the search you left out... in order to make that happen.  The tool of choice for this is often &lt;CODE&gt;eventstats&lt;/CODE&gt; - which acts like the &lt;CODE&gt;stats&lt;/CODE&gt; command but leaves the underlying events alone, merely adding the results to the underlying events.  Another useful tool is &lt;CODE&gt;appendpipe&lt;/CODE&gt; - which takes all the results, lets you process them in some way, and then adds them back as new events onto the end of the prior results.  And a third useful tool is a subsearch, where you go get certain information and feed that information back as a limit on the outer search.&lt;/P&gt;

&lt;P&gt;Which one of the above constructions performs best will be VERY data dependent.  So, you try each one and stop when you have acceptable performance, or pick the best of the unacceptable performances.  &lt;/P&gt;

&lt;P&gt;Now, you need to define what you mean by "the 10 most common paths".  You could mean the ones that were the 10 most common today, or this month.  you could mean the 10 paths that had the highest AVERAGE use, or the highest PEAK use, or the highest P90 use.  &lt;/P&gt;

&lt;P&gt;I'm going to assume the total count over the period of the search - which amounts to the same as average - for the purposes of these examples.  This first one filters off only the paths you want from your second search..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=... | timechart max(transTime) by path useother=false usenull=false
  | search [ your first search | top 10 by path | table path]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That way will work, but it is eliminating the unneeded paths after doing all the work of calculation.  Better to do it in the other order.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index= ... [ your first search | top 10 by path | table path]...
  ...
| timechart max(transTime) by path useother=false usenull=false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the field &lt;CODE&gt;path&lt;/CODE&gt; is not on the underlying records, then put the &lt;CODE&gt;search [...]&lt;/CODE&gt; as early as you can, in order to cull the records.  &lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 14:52:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400268#M115976</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-06-22T14:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400269#M115977</link>
      <description>&lt;P&gt;Hi @dsitek,&lt;/P&gt;

&lt;P&gt;Can you please try &lt;CODE&gt;where&lt;/CODE&gt; condition is your timechart search? like. &lt;CODE&gt;WHERE max in top10&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;My Sample search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | timechart count useother=f by source WHERE max in top10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please check following link for more information.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.1/SearchReference/Timechart#Where_clause_examples"&gt;http://docs.splunk.com/Documentation/Splunk/7.1.1/SearchReference/Timechart#Where_clause_examples&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Kamlesh &lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 15:03:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400269#M115977</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-06-22T15:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400270#M115978</link>
      <description>&lt;P&gt;This seems like it should be working but the search comes up empty. I am using rex statements to extract both the paths and transaction times. Is this affecting the search in some way?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 15:12:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400270#M115978</guid>
      <dc:creator>dsitek</dc:creator>
      <dc:date>2018-06-22T15:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400271#M115979</link>
      <description>&lt;P&gt;It could be.  Your best bet would be to try the subsearch on its own first.  Make sure it is returning the 10 paths you expect.   You will need the rex in both the inner and outer searches. &lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 15:19:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400271#M115979</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-06-22T15:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400272#M115980</link>
      <description>&lt;P&gt;@kmaron - Change &lt;CODE&gt;fields&lt;/CODE&gt; to &lt;CODE&gt;table&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;The difference is that &lt;CODE&gt;fields&lt;/CODE&gt; leaves present all the internal fields that start with underscore, like &lt;CODE&gt;_time&lt;/CODE&gt;, whereas &lt;CODE&gt;table&lt;/CODE&gt; gets rid of them.&lt;/P&gt;

&lt;P&gt;To see what &lt;CODE&gt;search index=... | stats count by path | top 10 path | fields path&lt;/CODE&gt; turns into when it hits the end of the square braces, feed it in a base search to the &lt;CODE&gt;format&lt;/CODE&gt; command.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=... | stats count by path | top 10 path | fields path | format
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You will see that there are other fields being attempted to be matched than just "path". &lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 19:17:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400272#M115980</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-06-22T19:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400273#M115981</link>
      <description>&lt;P&gt;@kamlesh_vaghela -   Awesome.  I learned something new today.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 19:26:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400273#M115981</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-06-22T19:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400274#M115982</link>
      <description>&lt;P&gt;that makes so much sense.  Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 19:28:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400274#M115982</guid>
      <dc:creator>kmaron</dc:creator>
      <dc:date>2018-06-22T19:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400275#M115983</link>
      <description>&lt;P&gt;@DalJeanis&lt;/P&gt;

&lt;P&gt;Thanks.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Jun 2018 04:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400275#M115983</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-06-23T04:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to Timechart for only the 10 highest counted values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400276#M115984</link>
      <description>&lt;P&gt;Same here. Thanks Kamlesh &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 05:48:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-Timechart-for-only-the-10-highest-counted-values/m-p/400276#M115984</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-02T05:48:46Z</dc:date>
    </item>
  </channel>
</rss>

