Retrieve latency percentiles from analytics API endpoint or custom reports

devin15
Participant I

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,313
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

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.

Sorry that GET command is an image. I embedded it as formatted code, but somehow that code wouldn't display. So I took a screenshot and embedded THAT. eugh.

Dino,

Does this management api call work for version 4.19.01.00 on-prem installations? I'm getting a "Data Access Error" error.

Yes, this call should work on prem.

I think this requires some diagnosis.

If I were diagnosing this, I would check the mgmt server system log.

And I might also engage Apigee support to help me diagnose.

Hi @Jon Sellers, I'm wondering if you found an answer to this issue? I'm also on on-prem 4.19.01 and I'm getting the Data Access Error when running the query below:

[apigee@a0110papimgmt01 ~]$ curl -u {username}:{password} http://{mgmt-server}/v1/o/{org}/environments/{env}/stats/request_verb,proxy_basepath,proxy_pathsuffi...?"t=agg_percentile&select=sum(message_count),min(total_response_time),max(total_response_time),avg(total_response_time),percentile(total_response_time,99)&timeRange=04/12/2020+16:00~04/13/2020+16:00&limit=100&timeUnit=day&sortby=sum(message_count)"
{
"code" : "analytics.dataapi.service.data_access_error",
"message" : "Data Access Error - Data Access Error",
"contexts" : [ ]
}