<?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 use tstats to calculate avg response times? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/614303#M213457</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;anyway to generate p99,p95,mean median values with this datasets ? Please help&lt;/P&gt;</description>
    <pubDate>Fri, 23 Sep 2022 13:00:00 GMT</pubDate>
    <dc:creator>dsenapaty</dc:creator>
    <dc:date>2022-09-23T13:00:00Z</dc:date>
    <item>
      <title>How to use tstats to calculate avg response times?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612673#M213014</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;
&lt;P&gt;I need help trying to generate the average response times for the below data using tstats command. Need help with the splunk query.&amp;nbsp; I am dealing with a large data and also building a visual dashboard to my management. So trying to use tstats as searches are faster. Stuck with unable to find avg response time using the value of Total_TT in my tstat command. When i execute the below tstat it is saying as it returned some number of events but the value is blank. Can someone help me with the query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample Data:&lt;/P&gt;
&lt;P&gt;2022-09-11 22:00:59,998 INFO -(Success:true)-(Validation:true)-(GUID:68D74EBE-CE3B-7508-6028-CBE1DFA90F8A)-(REQ_RCVD:2022-09-11T22:00:59.051)-(RES_SENT:2022-09-11T22:00:59.989)-(SIZE:2 KB)-(RespSent_TT:0ms)-(Actual_TT:938ms)-(DB_TT:9ms)-(Total_TT:947ms)-(AppServer_TT:937ms)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SPL Query:&lt;/P&gt;
&lt;P&gt;| tstats values(PREFIX(total_tt:)) as AVG-RT where index=test_data sourcetype="tomcat:runtime:log" TERM(guid)&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 16:01:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612673#M213014</guid>
      <dc:creator>dsenapaty</dc:creator>
      <dc:date>2022-09-12T16:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with tstats calculating avg response times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612675#M213016</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/65096"&gt;@dsenapaty&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I assume you are on Splunk version 8.x or higher since PREFIX is not supported on previous versions. The below search should work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats count where index=test_data sourcetype="tomcat:runtime:log" TERM(guid) by PREFIX(total_tt:) 
| rename "total_tt:" as total_tt 
| eval total_tt=replace(total_tt,"ms","") 
| stats avg(total_tt) as AVG-RT&lt;/LI-CODE&gt;&lt;P&gt;Please keep in mind that PREFIX does not work on hot buckets. Your latest data may not be included in the average calculation until the bucket rolls to warm.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 04:54:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612675#M213016</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2022-09-12T04:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with tstats calculating avg response times</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612762#M213033</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;Thanks i am now able to view the results but average calculations are not correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run the below tstat spl and normal spl without tstat i am getting different average results. But events that these two commands are pulling seems to be same.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 15:55:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612762#M213033</guid>
      <dc:creator>dsenapaty</dc:creator>
      <dc:date>2022-09-12T15:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tstats to calculate avg response times?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612793#M213045</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/65096"&gt;@dsenapaty&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I missed an important detail. Since we are grouping by the total_tt the same total_tt events are being grouped and that is why the average becomes wrong. Below should work correct.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats count where index=test_data sourcetype="tomcat:runtime:log" TERM(guid) by PREFIX(total_tt:) 
| rename "total_tt:" as total_tt 
| eval total_tt=tonumber(replace(total_tt,"ms","")) * count 
| stats sum(total_tt) as avgrt sum(count) as count 
| eval AVG-RT=round(avgrt/count,0) 
| fields AVG-RT&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 12 Sep 2022 20:59:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612793#M213045</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2022-09-12T20:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tstats to calculate avg response times?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612915#M213061</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;thanks a ton works perfectly.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 16:17:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/612915#M213061</guid>
      <dc:creator>dsenapaty</dc:creator>
      <dc:date>2022-09-13T16:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use tstats to calculate avg response times?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/614303#M213457</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;anyway to generate p99,p95,mean median values with this datasets ? Please help&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 13:00:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-tstats-to-calculate-avg-response-times/m-p/614303#M213457</guid>
      <dc:creator>dsenapaty</dc:creator>
      <dc:date>2022-09-23T13:00:00Z</dc:date>
    </item>
  </channel>
</rss>

