This example uses the GraphQL Analytics API to query metrics for your Containers. Two endpoints are available:
containersMetricsAdaptiveGroupsreturns metrics for the code running inside your container, including every process inside it. Use this endpoint to inspect CPU, memory, disk, network, and uptime behavior for your own workload.containersUsageAdaptiveGroupsreturns the resources consumed by your container together with the micro VM sandbox required to run it. These are the values that populate the usage estimates in the Cloudflare dashboard, and are the ones to use when estimating your billing costs.
Both endpoints share the same underlying dataset, but expose different slices of it.
Replace <CLOUDFLARE_ACCOUNT_TAG> and <API_TOKEN>1 with your Account ID and API token, and adjust the datetimeStart and datetimeEnd values for the time range you want to query.
Use containersMetricsAdaptiveGroups to understand how your container and its subprocesses are behaving. The numbers returned reflect resource usage of your own code and do not include any platform overhead.
Dimensions
You can group results by any of the following dimensions:
| Dimension | Description |
|---|---|
instanceId |
The container instance ID. This is the same ID shown in the Cloudflare dashboard and by Wrangler. |
placementId |
A single container instance can be placed in different locations over its lifetime (for example, when moved between data centers). Group by placementId to separate metrics across each placement. |
applicationId |
The Containers application the instance belongs to. |
location |
The Cloudflare data center where the container is running. |
region |
The region the container is running in. |
label(name: "...") |
The value of a specific container label. See Filter and group by labels. |
date, datetime, datetimeMinute, datetimeFiveMinutes, datetimeFifteenMinutes, datetimeHour, datetimeSixHours |
Time buckets of varying granularity. |
Metrics
The following metric groups are available. Each group exposes multiple fields — use GraphQL introspection or the GraphQL API Explorer to discover the full list.
| Group | Examples | Description |
|---|---|---|
count |
— | Number of metric samples received. |
avg |
memory, cpuUtilization, rxBandwidthBps, txBandwidthBps, gpuMemory, containerUptime |
Average of the metric over the selected time range. |
sum |
cpuTimeSec, allocatedMemory, allocatedDisk, allocatedCpu, rxBytes, txBytes, containerUptime |
Total value of the metric over the selected time range. |
max |
memory, cpuUtilization, diskUsage, diskUsagePercentage, rxBandwidthBps, txBandwidthBps, containerUptime |
Maximum observed value of the metric. |
quantiles |
memory, cpuUtilization, rxBandwidthBps, txBandwidthBps, diskUsage, diskUsagePercentage, gpuMemory, containerUptime |
Weighted quantiles. Each metric is available with a P50, P95, or P99 suffix (for example, memoryP95). |