<?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 How to get the maximum value from a timechart table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201166#M58292</link>
    <description>&lt;P&gt;Hi folks,&lt;/P&gt;

&lt;P&gt;I am trying to obtain the maximum value from any cell in a table generated by a timechart search.  For example, in the attached image the search string is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | timechart count by sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The time span automatically used is &lt;CODE&gt;1 day&lt;/CODE&gt;.  Based on this I want to receive the single value of &lt;CODE&gt;70434&lt;/CODE&gt; which occurs under the &lt;CODE&gt;splunkd&lt;/CODE&gt; column on &lt;CODE&gt;4/12/16&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;I can get the maximum value for each sourcetype with the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | timechart count by sourcetype | stats max(*) as *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However this doesn't get me the single value I want. &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1237iF1205CE861750924/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Apr 2016 01:55:05 GMT</pubDate>
    <dc:creator>avisram</dc:creator>
    <dc:date>2016-04-13T01:55:05Z</dc:date>
    <item>
      <title>How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201166#M58292</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;

&lt;P&gt;I am trying to obtain the maximum value from any cell in a table generated by a timechart search.  For example, in the attached image the search string is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | timechart count by sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The time span automatically used is &lt;CODE&gt;1 day&lt;/CODE&gt;.  Based on this I want to receive the single value of &lt;CODE&gt;70434&lt;/CODE&gt; which occurs under the &lt;CODE&gt;splunkd&lt;/CODE&gt; column on &lt;CODE&gt;4/12/16&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;I can get the maximum value for each sourcetype with the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | timechart count by sourcetype | stats max(*) as *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However this doesn't get me the single value I want. &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1237iF1205CE861750924/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 01:55:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201166#M58292</guid>
      <dc:creator>avisram</dc:creator>
      <dc:date>2016-04-13T01:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201167#M58293</link>
      <description>&lt;P&gt;1)  You want to use &lt;CODE&gt;untable&lt;/CODE&gt; to turn the chart/timechart style result set into a "stats style" result set,&lt;BR /&gt;&lt;BR /&gt;
then you can find the maximum value along with both the time value and the relevant value of the split-by field. &lt;/P&gt;

&lt;P&gt;Using your index=_internal example it would look like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | timechart count by sourcetype | untable _time sourcetype count | sort - count | head 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2) the other way to do it is to just use bin and stats instead of timechart in the first place, like so: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal | bin _time span="1h" | stats count by _time sourcetype | sort - count | head 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but then you have to do the binning by hand with the bin command.   &lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 01:59:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201167#M58293</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-04-13T01:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201168#M58294</link>
      <description>&lt;P&gt;Hi avisram,&lt;/P&gt;

&lt;P&gt;based on your example you can run this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal 
| timechart count by sourcetype 
| stats max(*) AS * 
| transpose 
| stats max(*) AS * 
| rename column AS sourcetype "row 1" AS count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and the result will look like this:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/1236i25FB777F659E1507/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:01:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201168#M58294</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-04-13T02:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201169#M58295</link>
      <description>&lt;P&gt;Thanks MuS and sideview for your responses.  Both of these methods give me the desired result.  Is one more efficient than the other?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:08:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201169#M58295</guid>
      <dc:creator>avisram</dc:creator>
      <dc:date>2016-04-13T02:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201170#M58296</link>
      <description>&lt;P&gt;Run the options with your real life events ( and your search ) and you will see in the job inspector which one will win &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; I reckon it's @sideview option 2&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:09:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201170#M58296</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2016-04-13T02:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201171#M58297</link>
      <description>&lt;P&gt;My money is on @sideview option 2!   I love the 2-dimensional &lt;CODE&gt;max(*) as *&lt;/CODE&gt; craziness though.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:16:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201171#M58297</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-04-13T02:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201172#M58298</link>
      <description>&lt;P&gt;Actually MuS' was faster - 1.76 to 1.894 over 274,899 events.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201172#M58298</guid>
      <dc:creator>avisram</dc:creator>
      <dc:date>2016-04-13T02:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201173#M58299</link>
      <description>&lt;P&gt;As I only need the value I modified MuS' search to the following:&lt;/P&gt;

&lt;P&gt;index=_internal | timechart count by sourcetype| stats max(*) as * | transpose | stats max("row 1") as value&lt;/P&gt;

&lt;P&gt;Thanks to both of you for your responses!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:41:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201173#M58299</guid>
      <dc:creator>avisram</dc:creator>
      <dc:date>2016-04-13T02:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201174#M58300</link>
      <description>&lt;P&gt;Strange. It really shouldn't be. And on my system &lt;CODE&gt;index=_internal | head 100000 | bin _time span="1h" | stats count by _time sourcetype | sort - count | head 1&lt;/CODE&gt;  is quite a lot faster than the other options.   I'm glad they all work for you though. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2016 07:17:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201174#M58300</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2016-04-13T07:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201175#M58301</link>
      <description>&lt;P&gt;Hi, I have a similar situation. But I need min,max and avg for each sourcetype. Using your query only one calculation can be done. Is there a way to include all 3 in a single table.&lt;/P&gt;

&lt;P&gt;index=* | extract pairdelim="," kvdelim=":" | table _time,* xml,* json&lt;BR /&gt;
 | stats max(* ) AS *&lt;BR /&gt;&lt;BR /&gt;
 | transpose &lt;BR /&gt;
 | rename column AS sourcetype "row 1" AS Max&lt;/P&gt;

&lt;P&gt;[*xml and *json because the fields are dynamic]&lt;/P&gt;</description>
      <pubDate>Sat, 24 Dec 2016 00:13:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201175#M58301</guid>
      <dc:creator>Roopaul</dc:creator>
      <dc:date>2016-12-24T00:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201176#M58302</link>
      <description>&lt;P&gt;I would like to find not only max but min also&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ndex=_internal 
 | timechart span=1h count by host
 | stats max(*) AS *."max", min(*) as *."min" | transpose
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but how put min into another column?&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2017 06:54:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201176#M58302</guid>
      <dc:creator>exmuzzy</dc:creator>
      <dc:date>2017-10-15T06:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201177#M58303</link>
      <description>&lt;P&gt;Hi exmuzzy,&lt;/P&gt;

&lt;P&gt;you can try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal 
| bin _time span=1h 
| stats count by host _time 
| stats max(*) AS *."max", min(*) as *."min" by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2017 19:50:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201177#M58303</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-10-15T19:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the maximum value from a timechart table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201178#M58304</link>
      <description>&lt;P&gt;Here's a way that doesn't require a transpose. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;some search here&amp;gt;
| eval rowmax=0
| foreach columnname* 
    [ eval rowmax=if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' &amp;gt; rowmax, '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', rowmax) ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You're essentially brute force comparing every column to find the max.&lt;/P&gt;</description>
      <pubDate>Sat, 02 May 2020 15:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-maximum-value-from-a-timechart-table/m-p/201178#M58304</guid>
      <dc:creator>supersleepwalke</dc:creator>
      <dc:date>2020-05-02T15:52:16Z</dc:date>
    </item>
  </channel>
</rss>

