---
title: "Get Time Series Metrics"
description: "Get time series metrics."
operation_id: "post-metrics-type-key[-summarize]"
method: "POST"
path: "/metrics/{type}/{key}"
tag: "Metrics"
base_url: "https://atomic-api.wordpress.com/api/v1.0/"
canonical_url: "https://wp.cloud/docs/api/endpoints/post-metrics-type-key-summarize.md"
---

# Get Time Series Metrics

[Tag index](https://wp.cloud/docs/api/tags/metrics.md) | [Reference index](https://wp.cloud/docs/api/reference.md) | [Agent guide](https://wp.cloud/docs/api/agent-guide.md) | [Source spec](https://wp.cloud/docs/api/openapi.json)

- Path variants: `/metrics/{type}/{key}`, `/metrics/{type}/{key}/summarize`
- Route note: The `/summarize` path segment is optional and enables the `summarize` behavior described by the endpoint.

## Description

Get time series metrics.

This endpoint queries a time series database and returns metrics that correspond to a site or client. Each metric can be further analyzed by specifying a dimension to segment the metric data on for sub analysis. In the API response an array of time periods are returned with each array item containing a `timestamp` field that specifies the start time of the span of time that the metric is reported for. The number of seconds for the span is given by the `data._meta.resolution` field in the response.

We support up to a 10 second resolution for recent data and metrics are downsampled into larger and larger minimum resolutions as time passes. Querying for a shorter and more recent time span will yield higher resolution data. Both longer time spans (longer time between the `start` and `end` parameters) as well as queries for older metrics data will result in lower resolution response data.

This endpoint supports returning multiple metrics per 1 dimension or up to 5 dimensions per 1 metric. By passing an array of metrics or dimensions to the metric and dimension field respectively.

Metrics can be pulled from multiple sources. Based on the Source different dimensions are available for segmentation. The API will respond with a 400 response if invalid metric, dimensions combinations are requested.

Supported metrics and dimensions to report are:

Edge Logs metrics
- `requests` - Number of requests
- `requests_persec` - Number of requests per second.
- `response_bytes` - Bandwidth consumed for all responses in bytes.
- `response_bytes_persec` - Bandwidth consumed for all responses in bytes per second.
- `response_bytes_average` - Average number of bytes of each response.
- `response_time_average` - (Default) Average response time of each response.

Edge Logs dimensions:
- `server_protocol` - Protocol version used by the client.
- `request_method` - Type of request made. (GET, POST, etc.)
- `http_host` - (Default) Hostname of the request.
- `http_status` - HTTP status code of the response.
- `http_user_agent` - HTTP User Agent of the request
- `referer_domain` - Referer Domain of the request
- `page_renderer` - The backend that handled the request (PHP, static file, etc.)
- `page_is_cached` - If the response page came from cache.
- `wp_admin_ajax_action` - For requests to the WP admin AJAX endpoint, which action was specified.
- `visitor_asn` - The ASN that the request came from.
- `visitor_country_code` - The country the request came from according to GeoIP.
- `visitor_is_crawler` - If the visitor appears to be an automated bot or crawler.
- `visitor_device_type` - The detected device that the request came from.
- `visitor_browser` - The detected browser that the request came from.
- `visitor_os` - The detected os that the request came from.
- `visitor_is_logged_in` - If the visitor appears to be logged in.
- `edge_cache_status` - Request Status from Edge.
- `is_rate_limited` - If the request was rate limited.
- `rate_limit_reason` - Reason for the request to be limited.
- `datacenter` - Datacenter that processed the request
- `path` - Request path/url without query string
- `remote_address` - IP that the request was issued from.
- `atomic_site_id` - WP Cloud Site ID associated with the request
- `proxy_type` - Type of proxy server that the request came from.

PHP Logs metrics
- `php_cpu_time` - Total CPU time.
- `php_cpu_time_persec` - CPU time per second.
- `php_response_time` - Total response time.
- `php_requests` - Number of requests .
- `php_requests_persec` - Number of requests per second.
- `php_workers_average` - Average number of php workers in use.
- `php_workers_min` - Minimum number of php workers in use.
- `php_workers_max` - Maximum number of php workers in use.
- `php_request_burst_percentage` - Percentage of requests in burst mode
- `php_request_limited_percentage` - Percentage of requests that were limited from burst mode.
- `php_request_normal_percentage` - Percentage of requests that were not in burst mode.

PHP logs dimensions:
- `http_verb` - Type of request made. (GET, POST, etc.)
- `http_host` - Hostname of the request
- `datacenter` - Datacenter that processed the request
- `atomic_site_id` - WP Cloud Site ID associated with the request
- `atomic_client_id` - WP Cloud Client ID associated with the request
- `burst_status` - Request Burst Status [BURST, LIMITED, -]

Uniques and Views metrics (aggregated from edge available as daily stat)
- `uniques` - Number of unique visitors
- `views` - Number of page views

Uniques and Views dimensions:
- `hostname` - Hostname.

MySQL UserStats metrics
- `mysql_total_connections` - number of connections.
- `mysql_concurrent_connections` - number of concurrent connections.
- `mysql_connected_time` - cumulative number of seconds elapsed while there were connections
- `mysql_busy_time` - cumulative number of seconds there was activity on connections
- `mysql_cpu_time` - cumulative CPU time elapsed, in seconds, while servicing connections
- `mysql_bytes_received` - number of bytes received
- `mysql_bytes_sent` - number of bytes sent
- `mysql_binlog_bytes_written` - number of bytes written to the binary log
- `mysql_rows_read` - number of rows read from tables
- `mysql_rows_sent` - number of rows sent to tables
- `mysql_rows_deleted` - number of rows deleted from tables
- `mysql_rows_inserted` - number of rows inserted to tables
- `mysql_rows_updated` - number of rows updated in tables
- `mysql_select_commands` - number of SELECT commands executed
- `mysql_update_commands` - number of UPDATE commands executed
- `mysql_other_commands` - number of OTHER commands executed
- `mysql_commit_transactions` - number of COMMIT commands issued
- `mysql_rollback_transactions` - number of ROLLBACK commands issued
- `mysql_denied_connections` - number of connections denied
- `mysql_lost_connections` - number of connections that were terminated uncleanly
- `mysql_access_denied` - number of issued commands that were denied.
- `mysql_empty_queries` - number of empty queries.
- `mysql_total_ssl_connections` - number of thread connections that used SSL.
- `mysql_max_statement_time_exceeded` - number of times a query has exceeded the maximum execution time

All mysql metrics have _persec variants.

MySQL Userstats dimensions:
- `pool` -  Pool Number
- `server` - Server Name
- `atomic_site_id` - WP Cloud Site ID

CGroup Userstats metrics:
- `cgroup_cpu_usage` - PHP CPU usage
- `cgroup_cpu_usage_persec` - PHP CPU usage per second

CGroup Userstats dimensions:
- `pool` -  Pool Number
- `server` - Server Name
- `atomic_site_id` - WP Cloud Site ID

OPcache metrics (site only, sampled once a minute, minimum resolution 60 seconds):
- `opcache_memory_max` - Peak bytes of OPcache memory held by the site.
- `opcache_hits` - Number of OPcache hits.
- `opcache_misses` - Number of OPcache misses.
- `opcache_hit_percentage` - Percentage of OPcache lookups that were hits.

OPcache dimensions:
- `pool` -  Pool Number
- `atomic_site_id` - WP Cloud Site ID

## Authentication

Requires `Auth` header. Scope is selected by `{type}` (`client` or `site`) and `{key}`.
OpenAPI security scheme `ApiKeyAuth` requires an API key in the `auth` header. The curl skeleton uses `Auth`; HTTP header names are case-insensitive.

## Usage Notes

- Required inputs: path parameters: `type`, `key`.
- OpenAPI-required top-level form fields: `start`, `end`.
- Optional query parameters: `summarize`.
- Request body content type: `application/x-www-form-urlencoded`.
- Documented responses: `200` success; `400` bad request - Invalid parameters or metric/dimension combination. The request is larger than a...; `403` access denied - Access denied or invalid client.; `404` not found - Site not found.; `429` rate limited - Metrics data source is busy. Honor the `Retry-After` response header (seconds) before...; `500` server error - Failed to connect to or query metrics data source..
- Documented top-level response fields: `data`, `message`.
- Includes 2 documented response examples below.
- Use one of the normalized path variants listed above; do not send raw legacy optional-segment syntax.
- The `/summarize` path segment is optional and enables the `summarize` behavior described by the endpoint.

## Request

`POST /metrics/{type}/{key}`

Path variants: `/metrics/{type}/{key}`, `/metrics/{type}/{key}/summarize`.

```bash
curl --location --request POST 'https://atomic-api.wordpress.com/api/v1.0/metrics/{type}/{key}?summarize=VALUE' \
  --header 'Auth: API_AUTH_TOKEN' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'start=VALUE' \
  --data-urlencode 'end=VALUE'
```

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `type` | path | string enum: `client`, `site` | yes | Type of metrics being requested. |
| `key` | path | string | yes | ID or name of requested type. |
| `summarize` | query | string | no | If present, returns an overall summary for the timespan given. |

## Request Body

Content type: `application/x-www-form-urlencoded`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `start` | number | required by schema | Unix timestamp for the start of the stats data range. |
| `end` | number | required by schema | Unix timestamp for the end of the stats data range. |
| `metric` | string or array | optional | Timeseries metric to report or array of metrics (Default: response_time_average). |
| `dimension` | string or array | optional | Dimension to slice the metric data by or array of dimensions (Default: http_host). |
| `resolution` | number | optional | Desired time resolution in seconds. The API will snap to the nearest supported resolution (10, 30, 60, 300, 600, 1800, 3600, 86400 seconds). Older data is automatically downsampled to coarser resolutions regardless of this value. |
| `max_bucket_size` | number | optional | Maximum number of time buckets to return (1-20). Default 20. |
| `filters` | array | optional | Filter to be applied to the metric request. |
| `filters.column` | string | optional | Dimension to be filtered. |
| `filters.operator` | string | optional | Operator: =, !=, >, >=, <, <=, IN, NOT IN. |
| `filters.value` | string or array | optional | Value to be compared. |


## Responses

| Code | Description | Fields |
| --- | --- | --- |
| `200` | Successful operation | `data`, `data.periods`, `data.periods[].dimension`, `data.periods[].timestamp`, `data._meta`, `data._meta.dimension`, `data._meta.end`, `data._meta.metric`, `data._meta.resolution`, `data._meta.start`, `data._meta.took`, `message` |
| `400` | Invalid parameters or metric/dimension combination. The request is larger than a metrics query may be (memory, rows or bytes). | `data`, `message` |
| `403` | Access denied or invalid client. | `data`, `message` |
| `404` | Site not found. | `data`, `message` |
| `429` | Metrics data source is busy. Honor the `Retry-After` response header (seconds) before retrying. | `data`, `message` |
| `500` | Failed to connect to or query metrics data source. | `data`, `message` |

### Response 200 fields

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | Response status message. |
| `data` | object | Response data. |
| `data._meta` | object | Metadata about the response data in `data.periods[]`. |
| `data._meta.start` | number | Unix timestamp for the start of the first period of data being reported (inclusive). |
| `data._meta.end` | number | Unix timestamp for the end of the last period of data being reported (exclusive). |
| `data._meta.resolution` | number | Number of seconds for each segment of data within `data.periods[]`. |
| `data._meta.metric` | string | Metric that is being reported. |
| `data._meta.dimension` | string | Dimension the metric is being segmented on. |
| `data._meta.took` | number | Backend response time for this timeseries query, in milliseconds. |
| `data.periods` | array<object> | Array of time period objects that span the timeseries response. |
| `data.periods[].timestamp` | number | Unix timestamp for the start of the particular period data is reported for. |
| `data.periods[].dimension` | object | Object where the key is the value of the dimension being segmented on and the value is the metric value. |

### Response 400 fields

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | Error message. |
| `data` | any | Error details, or an empty array when none are returned. |

### Response 403 fields

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | Error message. |
| `data` | any | Error details, or an empty array when none are returned. |

### Response 404 fields

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | Error message. |
| `data` | any | Error details, or an empty array when none are returned. |

### Response 429 fields

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | Error message. |
| `data` | any | Error details, or an empty array when none are returned. |

### Response 500 fields

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | Error message. |
| `data` | any | Error details, or an empty array when none are returned. |

## Examples

### 200 Success-Response (Single)

```json
{
    "message": "OK",
    "data": {
        "_meta": {
            "start": 1685577600,
            "end": 1685581200,
            "resolution": 300,
            "metric": "response_time_average",
            "dimension": "http_host",
            "took": 123
        },
        "periods": [
            {
                "timestamp": 1685577600,
                "dimension": {
                    "example.com": 0.03431913399587993
                }
            },
            {
                "timestamp": 1685580900,
                "dimension": {
                    "example.com": 0.050371567257529094
                }
            }
        ]
    }
}
```

### 200 Success-Response (Multiple Metrics)

```json
{
    "message": "OK",
    "data": {
        "_meta": {
            "start": 1685577600,
            "end": 1685581200,
            "resolution": 300,
            "metrics": [
                "response_bytes_average",
                "response_time_average"
            ],
            "dimensions": [
                "http_verb"
            ],
            "took": 123
        },
        "periods": [
            {
                "timestamp": 1685577600,
                "http_verb": {
                    "response_bytes_average": {
                        "GET": 42957.75494847475,
                        "HEAD": 0,
                        "OPTIONS": 10255.802443991854,
                        "POST": 1990.5416771631374
                    },
                    "response_time_average": {
                        "GET": 0.06258511425461395,
                        "HEAD": 0.3385846116680759,
                        "OPTIONS": 0.6501140529531567,
                        "POST": 0.4576846168664701
                    }
                }
            }
        ]
    }
}
```
