
I Tried Collecting CPU Utilization at 10-Second Intervals Using the Metric Category in Amazon EC2 Detailed Monitoring
This page has been translated by machine translation. View original
Introduction
On November 19, 2026, Amazon EC2 performance status checks and new EC2 Detailed Monitoring metrics were announced.
Detailed Monitoring now includes OpenTelemetry (OTel) format metrics, 1-minute GPU metrics, and 10-second CPU utilization. These metrics are selected by metric category, and you use them by associating that category with an instance. In this article, I mainly tried the 10-second CPU utilization.
Test Environment
- Region: ap-northeast-1
- Instance type: t3.micro
- AMI: Latest Amazon Linux 2023 (x86_64) AMI
- AWS CLI: 2.41.2
Setup
The quotas and billing for metric categories are described in the following official documentation.
Creating a Metric Category
I created a category by specifying CPUUtilization10Sec as the metric.
aws ec2 create-metric-category --metrics CPUUtilization10Sec
{
"MetricCategory": {
"MetricCategoryId": "mc-0123456789abcdef0",
"Metrics": [
"CPUUtilization10Sec"
]
}
}
Associating with an Instance
I launched one instance by specifying the category ID in --monitoring of run-instances. For --user-data, I saved the following load generation script as userdata-load.sh and passed it.
userdata-load.sh
#!/bin/bash
# Use up 2 cores for 20 seconds, then rest for 40 seconds. Repeat in a 60-second cycle
cat > /usr/local/bin/pulse.sh <<'PULSE'
#!/bin/bash
while true; do
for i in 1 2; do
timeout 20 sh -c 'while :; do :; done' &
done
wait
sleep 40
done
PULSE
chmod +x /usr/local/bin/pulse.sh
nohup /usr/local/bin/pulse.sh >/dev/null 2>&1 &
aws ec2 run-instances --image-id ami-0123456789abcdef0 --instance-type t3.micro --count 1 --monitoring Enabled=true,MetricCategoryIds=mc-0123456789abcdef0 --metadata-options HttpTokens=required --user-data file://userdata-load.sh
Running PromQL
OTel format metrics are retrieved with PromQL. The AWS CLI has no command for PromQL, so I sent requests signed with curl's --aws-sigv4 option. The destinations are /api/v1/query (instant query) and /api/v1/query_range (range query) on the monitoring endpoint. For authentication, I used temporary credentials (with a session token) extracted by aws configure export-credentials.
promql.sh
#!/bin/bash
# Usage: promql.sh <query|query_range> <PromQL> [start end step]
# Extract credentials from the AWS CLI into environment variables (do not write to a file)
set -euo pipefail
REGION=${AWS_REGION:-ap-northeast-1}
eval "$(aws configure export-credentials --format env)"
OP=$1; Q=$2
ARGS=(--data-urlencode "query=$Q")
if [ "$OP" = query_range ]; then
ARGS+=(--data-urlencode "start=$3" --data-urlencode "end=$4" --data-urlencode "step=$5")
fi
curl -sS --aws-sigv4 "aws:amz:${REGION}:monitoring" \
--user "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}" \
-H "x-amz-security-token: ${AWS_SESSION_TOKEN}" \
-w '\nhttp=%{http_code}\n' \
"${ARGS[@]}" "https://monitoring.${REGION}.amazonaws.com/api/v1/${OP}"
The IAM principal that runs PromQL needs permissions for cloudwatch:GetMetricData and cloudwatch:ListMetrics. This time I ran it with an administrator-equivalent role.
Measurement Results
10-Second Values and 1-Minute Values
The load repeats, in a 60-second cycle, a pattern of using up the CPU with two processes for 20 seconds and then resting for 40 seconds. The theoretical 1-minute average is 20/60 = 33.3%.
With get-metric-data, I retrieve the 10-second values and the 1-minute values for the same time range. I saved the query file as metric-queries.json. The Period is set to 10 for the 10-second values and 60 for the 1-minute values.
[
{"Id":"s10","MetricStat":{"Metric":{"Namespace":"AWS/EC2","MetricName":"CPUUtilization10Sec","Dimensions":[{"Name":"InstanceId","Value":"i-0123456789abcdef0"}]},"Period":10,"Stat":"Average"}},
{"Id":"m1","MetricStat":{"Metric":{"Namespace":"AWS/EC2","MetricName":"CPUUtilization","Dimensions":[{"Name":"InstanceId","Value":"i-0123456789abcdef0"}]},"Period":60,"Stat":"Average"}}
]
--start-time and --end-time are specified in UTC. 07:54Z to 08:00Z corresponds to 16:54 to 17:00 JST.
aws cloudwatch get-metric-data --start-time 2026-11-20T07:54:00Z --end-time 2026-11-20T08:00:00Z --metric-data-queries file://metric-queries.json --scan-by TimestampAscending --output json
For the 1-minute window from 16:57:00 to 16:57:59 JST, I listed the 6 points of CPUUtilization10Sec. CPUUtilization (the 1-minute value) for the same minute was 33.5%.
| Time | CPUUtilization10Sec (%) |
|---|---|
| 16:57:00 | 0.15 |
| 16:57:10 | 0.15 |
| 16:57:20 | 62.71 |
| 16:57:30 | 100.0 |
| 16:57:40 | 37.38 |
| 16:57:50 | 0.80 |
The 1-minute values were 33.4 to 33.7% at all 5 points from 16:54 to 16:58, close to the theoretical value. Of the 32 10-second points returned, 5 points (1 point every 60 seconds) were at 100%. The sum of the 3 points from 16:57:20 to 16:57:40 is about 200%, which corresponds to using two 10-second slots at 100%. The 20-second peak is averaged out to the 33% range in the 1-minute value.
Reflecting Category Changes
I checked whether a change to the category is reflected in already associated instances. With modify-metric-category, I replaced the category's metrics with two: CPUUtilization10Sec and instance.cpu.utilization. The metrics passed to --metrics replace the category's metrics entirely.
aws ec2 modify-metric-category --metric-category-id mc-0123456789abcdef0 --metrics CPUUtilization10Sec instance.cpu.utilization
{
"MetricCategory": {
"MetricCategoryId": "mc-0123456789abcdef0",
"Metrics": [
"CPUUtilization10Sec",
"instance.cpu.utilization"
]
}
}
CPUUtilization10Sec is in CloudWatch format and instance.cpu.utilization is in OTel format; they publish the same measurement in different formats. If you associate both with an instance, both formats are published and each is billed.
I measured the reflection after the change once. At intervals of about 16 seconds, I checked both with get-metric-data (CPUUtilization10Sec) and with PromQL (instance.cpu.utilization).
| Time | Type | Details |
|---|---|---|
| 17:00:35 | Operation | Ran modify-metric-category |
| 17:01:40 | Data point | First instance.cpu.utilization data point (PromQL timestamp; confirmed with a range query) |
| 17:02:13 | Query | PromQL instant query returned empty |
| 17:02:29 | Query | PromQL instant query returned a value |
CPUUtilization10Sec kept producing new data points after the change. The MetricCategoryIds in describe-instances remained the same ID before and after the change.
The official documentation describes passing the category ID to monitor-instances as the procedure for updating running and stopped instances after a category change. The same section also says that EC2 asynchronously updates associated instances after a modification or deletion. This time, the change was reflected on the instance even without calling monitor-instances.
OpenTelemetry Format
I retrieved instance.cpu.utilization with a PromQL range query. The metric name is written in quotes inside curly braces, and results are filtered by the instance ID label. start and end are Unix seconds. 1795161720 to 1795162080 corresponds to 17:02:00 to 17:08:00 JST on November 20, 2026. The step is 10 seconds.
./promql.sh query_range '{"instance.cpu.utilization","@resource.aws.ec2.instance.id"="i-0123456789abcdef0"}' 1795161720 1795162080 10
Values were returned with labels.
{"status":"success","data":{"resultType":"matrix","result":[{"metric":{"@aws.account":"123456789012","@aws.region":"ap-northeast-1","@instrumentation.@name":"cloudwatch.aws/ec2","@instrumentation.cloudwatch.solution":"detailed","@resource.aws.ec2.instance.id":"i-0123456789abcdef0","@resource.aws.ec2.instance.image.id":"ami-0123456789abcdef0","@resource.aws.ec2.instance.type":"t3.micro","@resource.cloud.account.id":"123456789012","@resource.cloud.provider":"aws","@resource.cloud.region":"ap-northeast-1","@resource.cloud.resource_id":"arn:aws:ec2:ap-northeast-1:123456789012:instance/i-0123456789abcdef0","__name__":"instance.cpu.utilization","__type__":"Gauge","__unit__":"%"},"values":[[1795161720.0,"0.75"],[1795161730.0,"0.0995619275189167"],[1795161740.0,"0.09999999999999999"],[1795161750.0,"62.223784652470876"],[1795161760.0,"100"],[1795161770.0,"37.63495106447382"],[1795161780.0,"0.1493428912783751"],[1795161790.0,"0.1004419445560466"],[1795161800.0,"0.15"],[1795161810.0,"61.9"],[1795161820.0,"100"],[1795161830.0,"37.21846278153722"],[1795161840.0,"0.7"],[1795161850.0,"0.14998500149985"],[1795161860.0,"0.1506629168340699"],[1795161870.0,"62.03325699492184"],[1795161880.0,"100"],[1795161890.0,"37.22222222222222"],[1795161900.0,"0.15"],[1795161910.0,"0.1506477854775534"],[1795161920.0,"0.09957184108334159"],[1795161930.0,"62.199999999999996"],[1795161940.0,"100"],[1795161950.0,"37.63332662507547"],[1795161960.0,"0.748652425633859"],[1795161970.0,"0.1506629168340699"],[1795161980.0,"0.0995619275189167"],[1795161990.0,"62.073121735636796"],[1795162000.0,"99.98000399920016"],[1795162010.0,"38.292998705308236"],[1795162020.0,"0.1506477854775534"],[1795162030.0,"0.15"],[1795162040.0,"0.15"],[1795162050.0,"61.75"],[1795162060.0,"99.98028002366397"],[1795162070.0,"37.27364185110664"],[1795162080.0,"1.008267795926598"]]}]}}
This range query returned 37 points. When I compared the values with CPUUtilization10Sec from get-metric-data (36 points from 17:02:00 to 17:07:50), all 36 points matched.
GPU Metrics and Performance Status Checks
This section was not verified on a GPU instance; it summarizes the announcement and the official documentation.
GPU metrics have a 1-minute period. You select them by putting metric names such as GPUUtilization (CloudWatch format) and instance.gpu.utilization (OTel format) into a category. The metrics are published only for supported instance types.
The announcement says that performance status checks identify non-terminating hardware conditions that affect the performance of accelerated computing instances. It also recommends remedies such as completing GPU memory row remapping by rebooting, without replacing the instance.
The Compute Blog includes an example describe-instance-status response for when the performance status check is impaired. In the example response, PerformanceStatus contains Status, ImpairedSince, and Remediation. It also says that StatusCheckFailed_Performance is published to CloudWatch.
Summary
By associating a metric category with an instance that has Amazon EC2 Detailed Monitoring enabled, I was able to obtain CPU utilization without any configuration inside the instance. OTel format metrics could also be retrieved with PromQL.
Conventional Detailed Monitoring had a 1-minute period, but CPU utilization can now be obtained at a 10-second period, enabling more detailed monitoring.
I did not try the GPU metrics this time, but if you need to monitor GPU instances, please check them out as well.
