View logs using the API

Download the API Monitoring logs to view the raw data used to calculate the metrics displayed in the API Monitoring dashboards. You can download logs for custom time ranges, specific proxies, specific status codes, and for many other variables.

The following sections describe how to manage logs by using the API:

See Logs API for more on the logs API.

For information about the cURL options used in these examples, see Use cURL.

Download logs for an organization and environment

Download the logs for a specific organization and environment by using the Logs API:

https://apimonitoring.enterprise.apigee.com/logs

You must pass the name of the organization and environment using the org and env query parameters.

By default, the API returns logs for the previous one hour. For example:

curl -X GET \
"https://apimonitoring.enterprise.apigee.com/logs?org=myorg&env=prod" \
-H "accept: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN"

Set $ACCESS_TOKEN to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token.

The response is an array of log entries in the form:

[   
  {
"request":"GET /v1/o/myorg/z HTTP/1.1",
    "request_length":1349,
    "request_message_id":"rrt-0623eb157b650315c-c-ne-7785-16029140-1",
    "virtual_host":"api.enterprise.apigee.com",
    "response_size":144,
    "response_time":0.551,
    "response_status":"404",
    "timestamp":"2018-08-14T17:31:07Z",
    "fault_code":"messaging.adaptors.http.flow.ErrorResponseCode",
    "fault_flow":"-",
    "fault_policy":"null/null",
    "fault_proxy":
        "/organizations/myorg/environments/prod/apiproxies/myAPI/revisions/50",
    "fault_source":"target"
  },
  …
]

Use the from and to query parameters to specify an ISO formatted time range. The date format can be either:

  • yyyy-mm-ddThh:mm:ssZ
  • yyyy-mm-ddThh:mm:ss+00:00

For example:

curl -X GET \
"https://apimonitoring.enterprise.apigee.com/logs?org=myorg&env=prod&from=2018-08-13T14%3A04%3A00Z&to=2018-08-13T14%3A10%3A00Z" \
-H "accept: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN"

The API has many optional query parameters. For example, to see the logs for a proxy named myAPI generating HTTP 404 responses:

curl -X GET \
"https://apimonitoring.enterprise.apigee.com/logs?org=myorg&env=prod&proxy=myAPI&status=404" \
-H "accept: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN"

For additional options, see the Logs API.

List the proxies associated with a virtual host and base path

A virtual host on an Edge Router lets you specify a domain name, protocol such as HTTP/HTTPS, and port number. For example, you define a virtual host on an Edge Router with the following settings:

  • host alias = apis.acme.com
  • port = 443
  • TLS enabled

Based on these settings, a request to an API proxy associated with this virtual host uses the form:

https://apis.acme.com/proxy-base-path/resource-path

Where:

  • proxy-base-path is defined when you create an API proxy and is unique for each API proxy.
  • resource-path is the path to a resource accessible through the API proxy.

For more on virtual hosts, see About virtual hosts.

Download the list of API proxies associated with a specific virtual host and base path by issuing a GET request to the following resource of the Logs API:

https://apimonitoring.enterprise.apigee.com/logs/apiproxies

You must pass the name of the organization and environment using the org and env query parameters as well as the URI associated with the virtual host and base path.

For example, the following API call returns the proxies associated with the virtual host http://apis.acme.com and with a base path of /v1/perf:

curl -X GET \
"https://apimonitoring.enterprise.apigee.com/logs/apiproxies?org=myorg&env=prod&select=http://apis.acme.com/v1/perf" \
-H "accept: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" 

Set $ACCESS_TOKEN to your OAuth 2.0 access token, as described in Obtain an OAuth 2.0 access token.

For additional options, see the Logs API.