Metrics Analytics API query with one proxy

Hi,

We have Apigee OPDK 4.51.x .

I was looking for query, which can give similar filtered query based on proxy name only.

Did not get that in the listed doc/link. Let me know if i am missing anything..

Below query, results in listing all proxies with message count. but i need a filter criteria hence I can put only one proxy name in the query and get result only for particular proxy (instead of listing for all proxies).

This is Apigee-X link using Metrics API feature and gives listed query to get such information.

curl -v "https://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/stats/?select=sum(message_count)&timeRange=03/01/2018%2000:00~03/31/2018%2023:59" \
  -H "Authorization: Bearer $TOKEN

 

curl  https://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/stats/apiproxy?"select=sum(message_count)&timeRange=06/20/2018%2000:00~06/21/2018%2023:59" \
  -H "Authorization: Bearer $TOKEN" 

 

https://cloud.google.com/apigee/docs/api-platform/analytics/analytics-referenceAnalytics metrics, di...

Above link lists Traffic message_count under Metrics section ( Following are the API metrics you can retrieve in custom reports and management API calls.)

https://cloud.google.com/apigee/docs/api-platform/analytics/use-analytics-api-measure-api-program-pe...

This is Apigee-X link using Metrics API feature and gives listed query to get such information.

curl -v "https://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/stats/?select=sum(message_count)&timeRange=03/01/2018%2000:00~03/31/2018%2023:59" \
  -H "Authorization: Bearer $TOKEN

@dino 

curl  https://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/stats/apiproxy?"select=sum(message_count)&timeRange=06/20/2018%2000:00~06/21/2018%2023:59" \
  -H "Authorization: Bearer $TOKEN" 

 

0 4 293
4 REPLIES 4

If I understand correctly, are you looking to query the analytics data for a particular API Proxy? If so, 'filters' should help you. 

Example: To filter metrics for proxy `foo` & `bar`:

curl -v "https://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/stats/?select=sum(message_count)&filter=(apiproxy%20in%20%27foo%27,%20%27bar%27)&timeRange=03/01/2018%2000:00~03/31/2018%2023:59" \
  -H "Authorization: Bearer $TOKEN

Reference Edge:  https://docs.apigee.com/api-platform/analytics/analytics-reference#filters
Reference ApigeeX: https://cloud.google.com/apigee/docs/api-platform/analytics/analytics-reference#filters

Thank you for using Apigee! 

 

 

Thanks @iambaskar  When i misspell proxy name, this query still gives 200 response with "metrics": [] with environment name. Is this expected behavior ? 

I was assuming it would complain about proxy name not being found. Let me know, if missing anything

 

Yes, it is expected. We don't validate the presence of apiproxy. We just filter the results to see whether any proxy matches to the value you pass in the filter. 

You can use filters like 

filter=(apiproxy like 'm%')

@iambaskar 

Thanks for your response.

Looking at above reference docs, to find out no traffic proxies, which are deployed to apigee , we follow listed 2 queries

Query 1) https://serverName:<port>/v1/o/<orgname>/e/<envname>/deployments

Based on above query, run below query

Query 2) https://servername:port/v1/o/<orgname>/e/<envname>/stats/apiproxy?select=sum(message_count)&sortby=s... in 'proxy1','proxy2','proxy3')

This results in both with and without traffic and will have to filter the result of no traffic proxies from above to know, proxies without traffic for listed date range.

Let me know, if you have any inputs.