Submitting API traffic statistics to Apigee

All Edge for Private Cloud customers are required to submit statistics about API proxy traffic to Apigee. Apigee recommends that you upload that information once a day, possibly by creating a cron job.

You must submit the statistics for your production API deployments, but not for APIs in development or testing deployments. In most Edge installations, you will define specific organizations or environments for your production APIs. The statistics that you submit are only for those production organizations and environments.

Submit your API traffic statistics to Apigee

To submit your statistcs to Apigee:

  1. Collect the data using the Edge management API.
  2. Send the data through email to: edge.apiops@google.com

You must repeat this process for every production organization and environment in your Edge installation.

Collect the data

Use the following curl command to gather traffic data for a specific organization and environment for a specified time interval:

curl -X GET -u apigee_mgmt_api_email:apigee_mgmt_api_password \
"http://ms_IP:8080/v1/organizations/org_name/environments/env_name/stats/apiproxy?select=sum(message_count)&timeRange=MM/DD/YYYY%20HH:MM~MM/DD/YYYY%20HH:MM&timeUnit=hour"

This command uses the Edge Get API message count API. In this command:

  • apigee_mgmt_api_email:apigee_mgmt_api_password specifies the email address of an account with access to the Edge /stats APIs.
  • ms_IP is the IP address or DNS name of the Edge Management Server.
  • org_name and env_name specifies the org and environment.
  • apiproxy is the dimenesion that groups metrics by API proxies.
  • MM/DD/YYYY%20HH:MM~MM/DD/YYYY%20HH:MM&timeUnit=hour specifies the time range divided into time units of the metrics to gather. Notice that the curl command uses the hex code %20 for spaces in the time range.

For example, to gather API proxy message counts hour by hour over a 24 hour period, use the following API call.

curl -X GET -u apigee_mgmt_api_email:apigee_mgmt_api_password \
"http://192.168.56.103:8080/v1/organizations/myOrg/environments/prod/stats/apiproxy?select=sum(message_count)&timeRange=01%2F01%2F2018%2000%3A00~01%2F02%2F2018%2000%3A00&timeUnit=hour"

(Note that timeRange contains URL-encoded characters.)

You should see a response in the form:

{
  "environments" : [ {
    "dimensions" : [ {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values": [
                {
                  "timestamp": 1514847600000,
                  "value": "35.0"
                },
                {
                  "timestamp": 1514844000000,
                  "value": "19.0"
                },
                {
                  "timestamp": 1514840400000,
                  "value": "58.0"
                },
                {
                  "timestamp": 1514836800000,
                  "value": "28.0"
                },
                {
                  "timestamp": 1514833200000,
                  "value": "29.0"
                },
                {
                  "timestamp": 1514829600000,
                  "value": "33.0"
                },
                {
                  "timestamp": 1514826000000,
                  "value": "26.0"
                },
                {
                  "timestamp": 1514822400000,
                  "value": "57.0"
                },
                {
                  "timestamp": 1514818800000,
                  "value": "41.0"
                },
                {
                  "timestamp": 1514815200000,
                  "value": "27.0"
                },
                {
                  "timestamp": 1514811600000,
                  "value": "47.0"
                },
                {
                  "timestamp": 1514808000000,
                  "value": "66.0"
                },
                {
                  "timestamp": 1514804400000,
                  "value": "50.0"
                },
                {
                  "timestamp": 1514800800000,
                  "value": "41.0"
                },
                {
                  "timestamp": 1514797200000,
                  "value": "49.0"
                },
                {
                  "timestamp": 1514793600000,
                  "value": "35.0"
                },
                {
                  "timestamp": 1514790000000,
                  "value": "89.0"
                },
                {
                  "timestamp": 1514786400000,
                  "value": "42.0"
                },
                {
                  "timestamp": 1514782800000,
                  "value": "47.0"
                },
                {
                  "timestamp": 1514779200000,
                  "value": "21.0"
                },
                {
                  "timestamp": 1514775600000,
                  "value": "27.0"
                },
                {
                  "timestamp": 1514772000000,
                  "value": "20.0"
                },
                {
                  "timestamp": 1514768400000,
                  "value": "12.0"
                },
                {
                  "timestamp": 1514764800000,
                  "value": "7.0"
                }
              ]
            }
          ],
          "name" : "proxy1"
      } ],
    "name" : "prod"
  } ],
  "metaData" : {
    "errors" : [ ],
    "notices" : [ "query served by:53dab80c-e811-4ba6-a3e7-b96f53433baa", "source pg:6b7bab33-e732-405c-a5dd-4782647ce096", "Table used: myorg.prod.agg_api" ]
  }
}