<?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 latencycount by each Api using stats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461962#M130215</link>
    <description>&lt;P&gt;I am just trying to get the latency count of API by taking the AVG responsetime of the API and using the avg as threshold, for example:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;api          totalCount          AvgRespTime        latencyCount&lt;BR /&gt;
XXX1        250                              5sec               it should be the count of the API XXX1 which exceeds the AvgRespTime of XXX1&lt;BR /&gt;
XXX2        300                              8sec                it should be the count of the API XXX2 which exceeds the AvgRespTime of XXX2.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I am trying the stats command as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats  count(Api) as totalcount avg(time) as AvgRespTime  count(eval(time&amp;gt;avg(time))) by latencycount by Api
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please help me how to get the latencycount by each Api using stats.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Aug 2019 16:33:26 GMT</pubDate>
    <dc:creator>tarunreddy_anth</dc:creator>
    <dc:date>2019-08-26T16:33:26Z</dc:date>
    <item>
      <title>How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461962#M130215</link>
      <description>&lt;P&gt;I am just trying to get the latency count of API by taking the AVG responsetime of the API and using the avg as threshold, for example:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;api          totalCount          AvgRespTime        latencyCount&lt;BR /&gt;
XXX1        250                              5sec               it should be the count of the API XXX1 which exceeds the AvgRespTime of XXX1&lt;BR /&gt;
XXX2        300                              8sec                it should be the count of the API XXX2 which exceeds the AvgRespTime of XXX2.&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I am trying the stats command as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats  count(Api) as totalcount avg(time) as AvgRespTime  count(eval(time&amp;gt;avg(time))) by latencycount by Api
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please help me how to get the latencycount by each Api using stats.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 16:33:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461962#M130215</guid>
      <dc:creator>tarunreddy_anth</dc:creator>
      <dc:date>2019-08-26T16:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461963#M130216</link>
      <description>&lt;P&gt;I am not sure what you are trying to do: your query seems to be wrong and incorrect&lt;/P&gt;

&lt;P&gt;do you mean this ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    | stats count(Api) as totalcount avg(time) as AvgRespTime latest(time) as time by Api 
    | eval latencycount=time-AvgRespTime 
    | fields - time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Aug 2019 18:40:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461963#M130216</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-08-26T18:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461964#M130217</link>
      <description>&lt;P&gt;I think you are want to use eventstats:&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Eventstats"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Eventstats&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.....
| eventstats avg(time) AS avgRespTime by api
| where time&amp;gt;avgRespTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will calculate the average response time across events, and trigger when that average is exceeded. &lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 18:50:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461964#M130217</guid>
      <dc:creator>solarboyz1</dc:creator>
      <dc:date>2019-08-26T18:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461965#M130218</link>
      <description>&lt;P&gt;eventstats may help here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search here)
| eventstats avg(duration) AS baseline BY api
| eval overbaseline=if(duration&amp;gt;baseline,"true",null())
| stats count AS totalcount avg(duration) AS AvgRespTime count(overbaseline) AS latencycount BY api
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any event over the baseline (the average) gets a field overbaseline with value true. Otherwise, it gets nothing.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 18:52:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461965#M130218</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-08-26T18:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461966#M130219</link>
      <description>&lt;P&gt;Mayurr, I want the count of the APIs that are above the Avg response time of the APIs&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 19:16:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461966#M130219</guid>
      <dc:creator>tarunreddy_anth</dc:creator>
      <dc:date>2019-08-26T19:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461967#M130220</link>
      <description>&lt;P&gt;Hi , Thanks for replying, I am trying to get the count of each APIs which exceeded their independent avg response time.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 19:29:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461967#M130220</guid>
      <dc:creator>tarunreddy_anth</dc:creator>
      <dc:date>2019-08-26T19:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461968#M130221</link>
      <description>&lt;P&gt;Hi, Jpolvino&lt;/P&gt;

&lt;P&gt;The result of latency count is just showing zeros&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 19:30:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461968#M130221</guid>
      <dc:creator>tarunreddy_anth</dc:creator>
      <dc:date>2019-08-26T19:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461969#M130222</link>
      <description>&lt;P&gt;correction: &lt;/P&gt;

&lt;P&gt;| stats  count(Api) as totalcount    avg(time) as AvgRespTime    count(eval(time&amp;gt;avg(time))) as latencycount    by Api&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 19:32:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461969#M130222</guid>
      <dc:creator>tarunreddy_anth</dc:creator>
      <dc:date>2019-08-26T19:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461970#M130223</link>
      <description>&lt;P&gt;Is stats generating any output?&lt;/P&gt;

&lt;P&gt;Is your duration in a field named "duration"? If not, then you'll need to replace duration with whatever fields contains the duration you want to measure.&lt;/P&gt;

&lt;P&gt;To test, you can also delete lines 3 and 4 from above, and change eventstats to stats, and see if that is working. If it works, then add line 3 (change stats back to eventstats on line 2) and take a look at events above and below each api's baseline value. You should see overbaseline=true for values greater than the api's average.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 20:11:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461970#M130223</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2019-08-26T20:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the latencycount by each Api using stats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461971#M130224</link>
      <description>&lt;P&gt;Add the &lt;EM&gt;by api&lt;/EM&gt; which will give you an average per API. &lt;/P&gt;

&lt;P&gt;If you want to aggregate those per run:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats avg(time) AS avgRespTime by api
| where time&amp;gt;avgRespTime
| stats count as count,  avg(time) as avgRespTime, by api
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The eventstats calculates the avg(time) by API and adds it to each event.&lt;BR /&gt;
The where filters on only those events were the avg was exceeded&lt;/P&gt;

&lt;P&gt;The final stats line, is to aggregate whatever statistics are needed from the sessions that exceeded the threshold.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 20:17:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-latencycount-by-each-Api-using-stats/m-p/461971#M130224</guid>
      <dc:creator>solarboyz1</dc:creator>
      <dc:date>2019-08-26T20:17:21Z</dc:date>
    </item>
  </channel>
</rss>

