Get Proxy Trafic from Apigee API Management on the last 6 months from today

Hi,

I'm using this doc https://docs-edgeapis.apigee.io/docs/metrics/1/routes/traffic/get to retrieve all traffic for one proxy and for one specific environment, however if my from and to query filters are over 1(one) day I get an error "time range exceeds 24h0m0s", this is crazy because the documentations says you can add a bigger period of time.

Below is the full URL

https://apimonitoring.enterprise.apigee.com/metrics/traffic?org={{org_name}}&interval=1d&groupBy=proxy&proxy={{proxy-name}}&env={{env}}&from=-2d&to=now&select=count 

Error 400

{
"error": "time range exceeds 24h0m0s"
}

 

1 2 178
2 REPLIES 2

That sounds frustrating. I know the engineering and product team working on stats and analytics has been re-working the stats backend to provide better performance and reliability. Maybe they introduced some limits and failed to update the documentation. If you please, file a bug on the doc page - I think you can provide feedback right in the browser page, and that should result in a bug logged against the docs.

I am SURE that the stats API (which may be different than the apimonitoring API) allows longer intervals in some cases. Have you tried the stats API? It would look like this:

 

GET https://api.enterprise.apigee.com/v1/organizations/ORG/environments/ENV/stats/apis
?select=sum(message_count)
&timeUnit=month
&timeRange=11/01/2023 07:00~11/30/2023 07:59

 

(all on one line)

I use timeUnit=month, and it allows a time duration of up to 180 days. I think if you don't specify a timeUnit in your query (as is the case in your example), then it may default to "minute". Are you sure you want and need by-the-minute tallies? Maybe you could use the /stats API with timeUnit=hour, and it will allow you to exceed 24h. Have you tried that? and will it suffice for you?

If you really DO want per-minute totals, then you will need a workaround. To do that you could break the time period into smaller segments and then merge the results. So if you want 21 days worth of data, then query for each day, and rollup those results into a single result. This could be done with some scripting if you know python or nodejs etc.

The API Traffic Summarizer tool still works, and takes this "roll up" approach for longer intervals (>180 days). It queries for each month and then merges the monthly totals. This tool may offer an illustration of what you could do, though I guess it will not be a immediate solution for you, because it does not perform the exact queries you want. You could modify it to do what you want.

Hi man, thanks to reply me. 

I got 400 Bad request with the Status API. The response is:

{
  "code": "analytics.dataaccess.api.InvalidAPICall",
  "message": "Invalid api call - INVALID_ARGUMENT: invalid argument: invalid dimensions - field \"apis \" not present in schema of exp-global-nonprod",
  "contexts": []
}

I created a ticket to Apigee support too, and they suggested me to use custom reports https://docs.apigee.com/api-platform/analytics/create-custom-reports.

This is what I'm trying now. No sure why the Status API does not worked, the error is not clear about invalid dimensions not be available.