Example: Generate a report on Origin Performance

To generate a report on Origin Performance with POST, prepare a base URL such as this:

/reporting-api/v1/reports/opresponses-by-time/versions/2/report-data

📘

Timestamps in the example are URL encoded. Decode these timestamps for clients that don't support encoded timestamps.

Additional query parameters set the range of the report and the interval each record represents. For example, you can specify an interval of a DAY. The example below shows how you would generate data over a range of a week. Since the report aggregates data per customer, data for each customer appears in separate records.

/reporting-api/v1/reports/opresponses-by-time/versions/2/report-data?interval=DAY&start=2017-05-10T00:00:00Z&end=2017-05-17T00:00:00Z

To prepare the query object for the POST request, you need a set of objectIds to report on, which for this type of report is a CP code. As listed in Available reports, you reflect that as an objectType of cpcode.

This sample request shows how you would specify an Origin Performance report provisioned under several CP codes. The request specifies a set of metrics:

{
  "objectType": "cpcode",
  "objectIds": [
    "536194", "536198", "539651", "539798", "539987"
  ],
  "filters": {},
  "metrics": [
    "originResponsesTotal",
    "originResponses",
    "originResponsesSlope",
    "minOriginResponseTime",
    "avgResponseTime",
    "maxOriginResponseTime"
  ]
}

The response's metadata section reflects context about the data you requested, based on both the supplied set of query parameters and the query request object. The groupBy indicates that the data is by start date (startdatetime).

Response data represents your full set of requested metrics, along with the objectId for each record. The following shows a small example of response output:

{
  "metadata": {
    "name": "opresponses-by-time",
    "version": "2",
    "groupBy": [
      "startdatetime"
    ],
    "interval": "FIVE_MINUTES",
    "start": "2017-09-18T04:00:00Z",
    "end": "2017-09-18T04:15:00Z",
    "availableDataEnds": "2017-09-18T04:10:00Z",
    "suggestedRetryTime": "2017-09-18T18:32:27.911Z",
    "rowCount": 3,
    "filters": [],
    "columns": [
      {
        "name": "originResponsesSlope",
        "label": "Origin Responses/Sec Slope"
      },
      {
        "name": "avgResponseTime",
        "label": "Average Origin Response Time "
      },
      {
        "name": "maxOriginResponseTime",
        "label": "Maximum Origin Response Time "
      },
      {
        "name": "minOriginResponseTime",
        "label": "Minimum Origin Response Time"
      },
      {
        "name": "originResponsesTotal",
        "label": "Origin Responses Total"
      },
      {
        "name": "originResponses",
        "label": "Origin Responses/Sec"
      }
    ],
    "objectType": "cpcode",
    "objectIds": [
      "536194", "536198", "539651", "539798", "539987"
    ]
  },
  "data": [
    {
      "minOriginResponseTime": "0",
      "maxOriginResponseTime": "2367",
      "avgResponseTime": "96.683065",
      "originResponses": "11.52",
      "startdatetime": "2017-09-18T04:00:00Z"
    },
    {
      "minOriginResponseTime": "2",
      "maxOriginResponseTime": "1293",
      "avgResponseTime": "61.359237",
      "originResponses": "14.50666666666667",
      "startdatetime": "2017-09-18T04:05:00Z"
    },
    {
      "minOriginResponseTime": "2",
      "maxOriginResponseTime": "2501",
      "avgResponseTime": "64.462784",
      "originResponses": "11.54",
      "startdatetime": "2017-09-18T04:10:00Z"
    }
  ],
  "summaryStatistics": {
    "originResponsesTotal": {
      "value": "11270",
      "details": {}
    },
    "originResponsesSlope": {
      "value": "0.0100000000000",
      "details": {}
    }
  }
}

Optionally specify a set of filters to refine the data, based on this report type. You can also vary the set of requested metrics as needed. This sample requests data only for minimum and maximum origin response times, and applies filters to consider only non-cacheable content requests:

{
    "objectType": "cpcode",
    "objectIds": [
      "536194", "536198", "539651", "539798", "539987"
    ],
    "metrics": [ "minOriginResponseTime", "maxOriginResponseTime" ],
    "filters": {
        "ca": [ "non-cacheable" ]
    }
}

📘

Response data aggregates according to the interval you specify. Some report types return aggregate data and some return time series data, which includes a timestamp for each interval in the response.