# Read a resource's metrics

Chart the metrics of an instance, a database, a VPN connection, a Kubernetes cluster, a CDN distribution or an app's deployments, or read the datapoints over the API.

Replace _i-1a2b3c4d_ with the id of the resource, as `dcloud monitoring metrics resources` lists
it. For what each metric means, see [Metrics](metrics.md).

## Prerequisites

- Permission for `monitoring:GetMetricData` on `rn:ews::<organization id>:monitoring:*`. Without it,
  the console's charts say "Metrics need monitoring:GetMetricData. Ask an administrator."
- To list the resources and their metrics, `monitoring:ListMetrics`.
- In the console, also the permission that opens the resource's own page in its service.

## Read the metrics

**Console**
1. Open the resource's page in its service: an instance, a Managed PostgreSQL database, a Document
   Database cluster, a Kubernetes cluster or a CDN distribution, and choose its **Monitoring** tab.
   For an app, choose **Metrics**; a site-to-site VPN connection's charts are with the connection
   on its gateway's page.
2. Choose a range: **1 hour**, **6 hours**, **24 hours**, **7 days** or **14 days**.
3. A database with several nodes, or an app with machines, has one button per node or machine;
   choose the one to chart. An app's first button, **Deployments**, charts its deployments.

The charts show the average per period. With `monitoring:DescribeAlarms`, the alarms on the
resource are listed under the charts.

**CLI**
```sh
dcloud monitoring metrics get-data --resource-type instance --resource-id i-1a2b3c4d \
  --metrics cpu_percent,network_in_bps --start 2026-10-29T10:00:00Z --period 300 --statistic max
```

**API**
```http
GET /monitoring/api/metrics/data?resourceType=instance&resourceId=i-1a2b3c4d&metrics=cpu_percent,network_in_bps&start=2026-10-29T10:00:00Z&period=300&statistic=max
```

## Result

The answer has one series per metric, each a list of `{ ts, value }` for the periods that have
data; empty periods are left out. A metric the resource type does not record, and an id your
organization does not have, answer empty series rather than an error.

## Limits

- 1 to 8 metrics per request.
- `statistic` is `avg` (the default), `max` or `min`; `sum` and `count` are accepted but answer the
  average.
- `period` is a whole number of minutes, from 60 to 86400 seconds (60 by default), and the range
  may hold at most 1440 periods. A longer range is refused with `400` "period: At most 1440 points
  per series: widen the period or narrow the range".
- `start` must be before `end` (which defaults to now). Points are kept 14 days.

## Related

- [Metrics](metrics.md)
- [Create an alarm](create-an-alarm.md)
- `monitoring.metrics.get-data` · `dcloud monitoring metrics get-data`
