Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Retrieve latency percentiles from analytics API endpoint or custom reports

I'm trying to extract percentiles for response times (i.e. total_response_time) via the analytics endpoint or custom reports. I only see the functions: sum, avg, min, max. The UI shows me percentiles, is there a way to extract this?

Solved Solved
1 5 1,511
1 ACCEPTED SOLUTION

I don't know why the API to retrieve percentiles is not documented.

Here is an example to get the 50th, 95th, and 99th percentile numbers for total response time by API Proxy for an organization and environment:

GET $mgmtserver/v1/o/$ORG/e/$ENV/stats/apiproxy,ax_dn_region?
  t=agg_percentile&
  select=percentile(total_response_time,50),percentile(total_response_time,95),percentile(total_response_time,99)&
  timeRange=10%2F1%2F2018+17:00:00~10%2F8%2F2018+17:00:00&
  timeUnit=minute&
  limit=2880

7521-screenshot-20181008-111456.png

All of that should appear on one line. Breaking down the query params:

parameter value comments
t agg_percentile table to query
select percentile(...),percentile(...)... percentiles to retrieve
timeRange 10%2F1%2F2018+17:00:00~10%2F8%2F2018+17:00:00 formatted and then url-encoded like the timeRange for other stats queries
timeUnit minute You can set this to hour and day, as well (I think!)
limit 2880 number of "time units", in this case, minutes. 2880 minutes is 2 days.

You can get {50,95,99} percentiles for

  • total_response_time
  • request_processing_latency
  • response_processing_latency
  • target_response_time

There are some additional query params supported, the same as documented for the other stats queries:

  • If you add the _optimized=js query parameter, It shapes the JSON differently (smaller).
  • You can also add sort=ASC or sort=DESC.
  • and a sortby query param that accepts the same things as "select".
  • You can also filter the results, by appending a filter query param. It takes values like:
    • (apiproxy in 'api1','api2')
    • (response_status_code eq 200)

    If you use curl, You need to url-encode the spaces, so the queryparam name and value would look like this:

    filter=(apiproxy%20in%20'my-proxy-name')
    

Good luck.

View solution in original post

5 REPLIES 5