<?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: Max/Min/Avg TPS in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672180#M230285</link>
    <description>&lt;P&gt;Hi!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for taking the time, sadly this didn't work out for me.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Ideally if I can keep the same format of:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| timechart span=1s count AS TPS&lt;BR /&gt;| eventstats max(TPS) as peakTPS&lt;BR /&gt;| eval peakTime=if(peakTPS==TPS,_time,null())&lt;BR /&gt;| stats avg(TPS) as avgTPS first(peakTPS) as peakTPS first(peakTime) as peakTime&lt;BR /&gt;| fieldformat peakTime=strftime(peakTime,"%x %X")&lt;BR /&gt;&lt;BR /&gt;With the addition of a couple lines for Min TPS and when it took place that would be ideal.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Dec 2023 11:03:57 GMT</pubDate>
    <dc:creator>WanLohnston</dc:creator>
    <dc:date>2023-12-18T11:03:57Z</dc:date>
    <item>
      <title>Max/Min/Avg TPS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672168#M230281</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have this query:&lt;BR /&gt;&lt;BR /&gt;| timechart span=1s count AS TPS&lt;BR /&gt;| eventstats max(TPS) as MaxPeakTPS&lt;BR /&gt;| stats avg(TPS) as avgTPS first(peakTPS) as peakTPS first(peakTime) as peakTime&lt;BR /&gt;| fieldformat peakTime=strftime(peakTime,"%x %X")&lt;BR /&gt;&lt;BR /&gt;This currently outputs Max TPS when Max TPS took place as well as the AVG TPS. I was wondering if it's possible to also display Min TPS and when that took place?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;TIA&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 09:39:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672168#M230281</guid>
      <dc:creator>WanLohnston</dc:creator>
      <dc:date>2023-12-18T09:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min/Avg TPS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672178#M230284</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/263423"&gt;@WanLohnston&lt;/a&gt;&amp;nbsp;you can try something like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|  timechart span=1d count(myfield) as nb_myfield |  eventstats min(myfield) as min_fields max(myfield) as max_fields avg(myfield) as moy_fields&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 10:57:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672178#M230284</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2023-12-18T10:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min/Avg TPS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672180#M230285</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for taking the time, sadly this didn't work out for me.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Ideally if I can keep the same format of:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;| timechart span=1s count AS TPS&lt;BR /&gt;| eventstats max(TPS) as peakTPS&lt;BR /&gt;| eval peakTime=if(peakTPS==TPS,_time,null())&lt;BR /&gt;| stats avg(TPS) as avgTPS first(peakTPS) as peakTPS first(peakTime) as peakTime&lt;BR /&gt;| fieldformat peakTime=strftime(peakTime,"%x %X")&lt;BR /&gt;&lt;BR /&gt;With the addition of a couple lines for Min TPS and when it took place that would be ideal.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 11:03:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672180#M230285</guid>
      <dc:creator>WanLohnston</dc:creator>
      <dc:date>2023-12-18T11:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min/Avg TPS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672203#M230287</link>
      <description>&lt;P&gt;Tried this out and came back with this. Format might be a little different than what you asked for but I think tells the same story.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| bucket span=1m _time
    | stats
        count as TPS
            by _time
    | eventstats
        min(TPS) as min_TPS,
        max(TPS) as max_TPS
    | foreach *_TPS
        [
            | eval
                &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS_epoch=if(
                    'TPS'=='&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS',
                        mvappend(
                            '&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS_epoch',
                            '_time'
                            ),
                        '&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS_epoch'
                    )
            ]
    | stats
        avg(TPS) as avg_TPS,
        first(*_TPS) as *_TPS,
        first(*_TPS_epoch) as *_TPS_epoch
    | eval
        avg_TPS=round('avg_TPS', 2)
    | foreach *_TPS_epoch
        [    
            | eval
                &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS_timestamps=case(
                    mvcount('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')==1, strftime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "%x %X"),
                    mvcount('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')&amp;gt;1, mvmap('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', strftime('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "%x %X"))
                    ),
                &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS_json=json_object(
                    "type", "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;",
                    "TPS", '&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS',
                    "Timestamps", '&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS_timestamps'
                    ),
                combined_TPS_json=mvappend(
                    'combined_TPS_json',
                    '&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_TPS_json'
                    )
            ]
    | fields + combined_TPS_json, avg_TPS
    | addinfo
    | eval
        search_time_window_end=strftime(info_max_time, "%x %X"),
        search_time_window_start=strftime(info_min_time, "%x %X"),
        avg_TPS_time_window='search_time_window_start'." --&amp;gt; ".'search_time_window_end'
    | eval
        combined_TPS_json=mvappend(
            'combined_TPS_json',
            json_object(
                "type", "avg",
                "TPS", 'avg_TPS',
                "Timestamps", 'avg_TPS_time_window'
                )
            )
    | mvexpand combined_TPS_json
    | fromjson combined_TPS_json
    | fields - combined_TPS_json
    | fields + type, TPS, Timestamps&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Output should look something like this.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_1-1702917740960.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28572i6272C821E1F59B83/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_1-1702917740960.png" alt="dtburrows3_1-1702917740960.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You should also be able to change the time bucket span form 1m back to 1s since that is how it was setup in your initial query.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 16:45:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672203#M230287</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-18T16:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Max/Min/Avg TPS</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672220#M230290</link>
      <description>&lt;P&gt;I assume that there is a typos in your MaxPeakTPS in the eventstats command and your use of peakTPS in the following stats and also the use of peakTime, which does not exist as a field.&lt;/P&gt;&lt;P&gt;You can do this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| timechart span=1s count AS TPS
``` Calculate min and max TPS ```
| eventstats max(TPS) as max_TPS min(TPS) as min_TPS
``` Now work out average TPS, actual min and max TPS and then the first 
    occurrence of the min/max TPS ```
| stats avg(TPS) as avgTPS values(*_TPS) as *_TPS 
        min(eval(if(TPS=max_TPS, _time, null()))) as maxTime
        min(eval(if(TPS=min_TPS, _time, null()))) as minTime
| fieldformat maxTime=strftime(maxTime,"%x %X")
| fieldformat minTime=strftime(minTime,"%x %X")&lt;/LI-CODE&gt;&lt;P&gt;The min(eval... statements just look for the first _time when TPS is either min or max to get the earliest time when these occurred.&lt;/P&gt;&lt;P&gt;Note the use of field naming conventions min_TPS/max_TPS that allows the use of wildcards in the stats.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 21:44:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Max-Min-Avg-TPS/m-p/672220#M230290</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-12-18T21:44:32Z</dc:date>
    </item>
  </channel>
</rss>

