CloudWatch Custom Metrics: How to Create Them, How They Are Counted, Pricing Examples, GetMetricData Costs and Ten Ways to Cut the Bill

Logeshwaran
—

A CloudWatch custom metric is any number your own code or tools send to CloudWatch, such as orders placed, queue depth or memory used. You create one by publishing it: aws cloudwatch put-metric-data, boto3's put_metric_data, the Embedded Metric Format (EMF) in your logs, the CloudWatch agent, or a log metric filter. Pricing (US East): the first 10 metrics are free, then $0.30 per metric per month for the first 10,000, $0.10 for the next 240,000 and $0.05 beyond, prorated by the hour and charged only in hours you publish. The catch is how metrics are counted: every unique combination of namespace, metric name and dimensions is a separate metric, so a dimension like customer ID can turn 3 metrics into thousands. The other common surprise is "CW:GMD-Metrics" on your bill: GetMetricData reads at $0.01 per 1,000 metrics, usually from dashboards or monitoring tools polling CloudWatch. Below: how to create custom metrics four ways, how they are counted, pricing tables with worked examples, GetMetricData vs metric streams, finding what is costing you, and ten ways to cut the bill.

Jake added three metrics to the shop's checkout service: orders, failed payments and checkout time. Sensible. He gave each one a "CustomerId" dimension so he could look up any customer's experience. The next month's CloudWatch line was several hundred dollars, because three metrics times a few thousand customers is not three metrics. Ethan's diagnosis took two minutes; the fix took one line.

⚡ Quick Answer

• Create one: put-metric-data, boto3, EMF logs or the agent. Four ways.

• Price: $0.30 per metric per month (first 10,000), first 10 free. Tables.

• Big bill? Usually dimensions with many values, or GetMetricData polling. How they count.

• Cut it: drop high-cardinality dimensions, stop polling, use streams. Ten fixes.

What metrics are · Worked examples · CW:GMD-Metrics · Find the cost · Read metrics back.

New to CloudWatch? The cards below cover CloudWatch itself, its logs bill, alarms and the other surprise charges worth knowing about.

🧭 NEW HERE? READ THESE FIRST

New to CloudWatch or AWS costs? These five pages give you the background this one builds on:

📌 Bookmark this; the pricing tables and the ten fixes are the parts you will come back for.

What are CloudWatch metrics?

What is a CloudWatch metric? A named series of numbers over time, such as CPU utilization every minute, or orders placed every time someone checks out. AWS services publish their own metrics for free (EC2 CPU at 5-minute intervals, Lambda invocations, ALB request counts); these are the "AWS/..." namespaces. A custom metric is one you publish yourself, in your own namespace, and that is what you pay for. Our CloudWatch explainer covers metrics, logs and alarms together.

Every metric is identified by three things:

  • Namespace: a container, such as Shop/Checkout.
  • Metric name: such as OrdersPlaced.
  • Dimensions: up to 30 name/value pairs that slice the metric, such as Environment=prod or Region=uk.

How long the data is kept depends on its resolution: 1-minute data for 15 days, 5-minute data for 63 days and hourly data for 455 days (15 months); high-resolution data under a minute is kept at that detail for 3 hours. You cannot delete a metric: it simply stops existing, and stops costing, once you stop publishing to it.

How to create custom metrics in CloudWatch: four ways

1. The AWS CLI, for scripts and cron jobs:

aws cloudwatch put-metric-data --namespace "Shop/Checkout" \
  --metric-name OrdersPlaced --value 1 --unit Count \
  --dimensions Environment=prod

2. boto3 (Python), batching several values in one call to save requests:

import boto3

cw = boto3.client("cloudwatch", region_name="eu-west-2")
cw.put_metric_data(
    Namespace="Shop/Checkout",
    MetricData=[
        {"MetricName": "OrdersPlaced", "Dimensions": [{"Name": "Environment", "Value": "prod"}],
         "Value": 1, "Unit": "Count"},
        {"MetricName": "CheckoutTime", "Dimensions": [{"Name": "Environment", "Value": "prod"}],
         "Values": [412, 380, 901], "Counts": [1, 1, 1], "Unit": "Milliseconds"},
    ],
)

The Values/Counts form sends many observations in one entry, which is how you report latencies without one call per request. Add "StorageResolution": 1 for a high-resolution (per-second) metric, only when you truly need it.

3. Embedded Metric Format (EMF), the cheapest way from Lambda and containers: print a JSON log line with an _aws block, and CloudWatch Logs extracts the metric for you, with no PutMetricData calls at all:

{"_aws": {"Timestamp": 1792500000000,
          "CloudWatchMetrics": [{"Namespace": "Shop/Checkout",
                                 "Dimensions": [["Environment"]],
                                 "Metrics": [{"Name": "OrdersPlaced", "Unit": "Count"}]}]},
 "Environment": "prod", "OrdersPlaced": 1, "CustomerId": "C-778", "OrderId": "A-1042"}

Notice CustomerId and OrderId: they are in the log line but not in Dimensions, so they are searchable with Logs Insights without creating a metric per customer. That is the fix Jake needed. You pay for the log ingestion (see our CloudWatch Logs cost guide) plus the extracted metrics.

4. The CloudWatch agent on EC2 or on-premises servers, for memory and disk usage, which EC2 does not report on its own. Each metric it collects (such as mem_used_percent in the CWAgent namespace) is a custom metric, multiplied by its dimensions, so collect only what you will look at.

A fifth route, metric filters on log groups, turns matching log lines ("ERROR", a status code) into a metric; those are custom metrics too.

Metric filter, EMF or Logs Insights? All three turn logs into numbers, at different points and prices:

  • Metric filters suit logs you do not control, such as a third-party app or a web server's access log. A JSON filter pattern like { $.level = "ERROR" } counts matching lines; a filter can also extract a numeric field as the value, and can add up to three dimensions taken from the log. Filters only apply to log lines that arrive after you create them; they never backfill old logs.
  • EMF suits your own code: you decide the metric at the moment you write the log line, with no filter to maintain.
  • Logs Insights answers one-off questions over logs you already have, including old ones, with no metric created at all. You pay per gigabyte scanned when you run a query, so it is ideal for "how many failed checkouts for customer C-778 last Tuesday" and wrong for a graph refreshed every minute.

A common good pattern combines them: EMF for the handful of metrics you alarm on, every other detail as JSON log fields, and Logs Insights for the questions that come up once.

Jake: "So EMF lets me keep CustomerId in the logs without paying for it as a metric?"

Ethan: "Right. Dimensions are what you'll graph and alarm on. Everything else stays a log field."

EMF in practice: the libraries that write it for you

Writing EMF JSON by hand works, but two libraries do it for you and get the details right (timestamps, batching, the 100-metrics-per-line limit).

Powertools for AWS Lambda (Python), the usual choice in Lambda functions:

from aws_lambda_powertools import Metrics
from aws_lambda_powertools.metrics import MetricUnit

metrics = Metrics(namespace="Shop/Checkout", service="checkout")

@metrics.log_metrics
def handler(event, context):
    metrics.add_dimension(name="Environment", value="prod")
    metrics.add_metric(name="OrdersPlaced", unit=MetricUnit.Count, value=1)
    metrics.add_metadata(key="CustomerId", value=event["customer_id"])   # a log field, not a dimension
    return {"ok": True}

The aws-embedded-metrics library, for containers and servers as well as Lambda:

from aws_embedded_metrics import metric_scope

@metric_scope
def record_order(order, metrics):
    metrics.set_namespace("Shop/Checkout")
    metrics.put_dimensions({"Environment": "prod"})
    metrics.put_metric("OrdersPlaced", 1, "Count")
    metrics.put_metric("CheckoutTime", order["ms"], "Milliseconds")
    metrics.set_property("OrderId", order["id"])

Both follow the same rule that saved Jake's bill: dimensions are for the few things you graph and alarm on (environment, service, perhaps Region), and everything else goes in as metadata or properties, which land in the log line where Logs Insights can search them. One more detail worth knowing: Powertools adds the service name as a dimension by default, so count it when you work out how many metrics you are creating.

Outside Lambda, EMF needs a way to reach CloudWatch Logs: the CloudWatch agent on EC2 or on-premises, or the container's log driver sending stdout to a log group on ECS and EKS. If the metrics never appear, check that the log lines arrive in the log group first; a metric cannot be extracted from a log line CloudWatch never received.

Use the free AWS metrics first

Before you publish a custom metric, check whether AWS already publishes it for free. Many teams pay to re-create numbers that sit in the AWS/ namespaces at no charge:

  • Lambda: invocations, errors, duration (with percentiles), throttles and concurrent executions, per function.
  • Application Load Balancer: request count, target response time, HTTP 4xx and 5xx counts, healthy and unhealthy host counts.
  • API Gateway: count, latency, integration latency, 4XXError and 5XXError.
  • SQS: messages visible and in flight, and the age of the oldest message, which is the best single "is my worker keeping up?" number.
  • DynamoDB, RDS, ECS: consumed capacity, throttles, connections, CPU and memory reservation and use.

Alarms on these still cost the normal alarm price, but the metrics themselves are free. A custom "request count" or "error count" in a Lambda function behind API Gateway usually duplicates what API Gateway and Lambda already report. Keep your own metrics for what AWS cannot see: business events (orders, sign-ups, payments), application-level timings inside a request, and anything about your own data.

Jake: "I was publishing Lambda duration as a custom metric."

Ethan: "Lambda already does, for free, with percentiles. Delete yours and point the dashboard at AWS/Lambda."

Designing a small, useful set of custom metrics

The cheapest metric is the one you never create. Before publishing anything, decide what you will alarm on and what you will graph, and publish only those. For a typical web service, a short list covers almost every question:

MetricStatistic you will useWhy it earns its place
Requests (count)Sum per minuteTraffic level; a sudden drop is often the first sign of an outage
Errors (count)Sum, and errors divided by requestsThe alarm almost everyone needs
Duration (milliseconds)p50, p95, p99What users feel; the tail matters more than the average
One business number (orders, sign-ups)Sum per 5 minutesCatches failures no technical metric sees, such as a broken payment form
Saturation (queue depth, pool in use)MaximumWarns before things slow down

Five metrics, with dimensions for environment and service only, is 10-20 billable metrics for a small app across two environments: a few dollars a month. A team can grow it as real questions come up, rather than starting with a hundred metrics "just in case".

Name things so the next person can guess them: one namespace per application (Shop/Checkout, Shop/Search), metric names in plain words (OrdersPlaced, not op_cnt), and the same dimension names everywhere (Environment, never sometimes Env). Consistent names make Metrics Insights queries and cross-service dashboards possible later, and they keep two spellings of the same thing from becoming two billable metrics.

From Node.js, and checking a new metric arrived

The same PutMetricData call from Node.js with the AWS SDK v3, batching two metrics in one request:

import { CloudWatchClient, PutMetricDataCommand } from "@aws-sdk/client-cloudwatch";

const cw = new CloudWatchClient({ region: "eu-west-2" });
const dims = [{ Name: "Environment", Value: "prod" }];

await cw.send(new PutMetricDataCommand({
  Namespace: "Shop/Checkout",
  MetricData: [
    { MetricName: "OrdersPlaced", Dimensions: dims, Value: 1, Unit: "Count" },
    { MetricName: "CheckoutTime", Dimensions: dims, Values: [412, 380], Counts: [1, 1], Unit: "Milliseconds" },
  ],
}));

"I published it, but the metric isn't there." Three normal delays and two real problems explain almost every case:

  • Listing lags behind data. A brand-new metric can take several minutes to appear in list-metrics and the console's browse view, even though get-metric-statistics for the exact name and dimensions may already return data.
  • Old timestamps arrive slowly. Data points stamped hours in the past can take much longer to become queryable than fresh ones, which matters when you backfill.
  • The console's time range and period. A one-off data point is invisible on a graph set to a period longer than the range or to an unrelated statistic; check with the Sum statistic and a 1-minute period.
  • The wrong Region or namespace. The client's Region decides where the metric lives; a typo in the namespace creates a separate one.
  • A silent permission or EMF problem. PutMetricData without permission raises an error your code may swallow; for EMF, a malformed _aws block simply produces no metric, so validate one log line by hand first.

How CloudWatch metrics are counted

This is the section that explains most surprise bills. A metric, for billing, is one unique combination of namespace + metric name + dimension names and values. The number of data points does not matter; the number of combinations does.

  1. Start with your metric names: OrdersPlaced, FailedPayments, CheckoutTime = 3.
  2. Multiply by every value of each dimension: Environment (prod, staging) = ×2. That is 6 metrics, about $1.80 a month.
  3. Add a dimension with many values: CustomerId with 3,000 customers = ×3,000. Now it is 18,000 metrics.
  4. Price it: 10,000 × $0.30 + 8,000 × $0.10 = $3,800 a month if every combination is published all month; less if each customer only appears a few hours (proration), which is why the bill was "only" several hundred.
  5. Remove the dimension, keep CustomerId as an EMF log field, and you are back to 6 metrics.

A quick way to estimate before you ship: for each metric name, multiply the number of distinct values of each of its dimensions, then add up across metric names. If any single dimension could have more than a few dozen values (users, sessions, orders, URLs, error messages, IP addresses, container IDs), stop and ask whether you will ever alarm on one value of it. If not, it belongs in a log field.

Two other multipliers people miss: each different set of dimensions on the same metric name is another metric (publishing OrdersPlaced with {Environment} and with {Environment, Region} makes two families), and agent configs that add InstanceId to every metric multiply by your instance count. Proration helps short-lived combinations: a metric published for one hour costs about $0.30 / 730 hours, so dimensions on auto-scaled instance IDs cost far less than their count suggests.

CloudWatch metric pricing, in tables

US East (N. Virginia) prices; other Regions differ slightly.

ItemPriceFree tier
Custom and detailed monitoring metrics, first 10,000$0.30 per metric per month10 metrics
Next 240,000 metrics$0.10 per metric per month
Beyond 250,000 metrics$0.05 per metric per month (lower again at very high volumes)
GetMetricData (reading metrics by API)$0.01 per 1,000 metrics requestedNone: always charged
Other API requests (PutMetricData, ListMetrics, GetMetricStatistics...)Billed per request beyond the free tier1 million requests
Metric streams$0.003 per 1,000 metric updates, plus Firehose
Dashboards$3.00 per dashboard per month3 dashboards (up to 50 metrics each); automatic dashboards free
Alarms$0.10 per standard alarm metric, $0.30 high-resolution, $0.50 composite10 standard alarm metrics

Metric charges are prorated by the hour and only apply in hours when the metric receives data. EC2 detailed monitoring (1-minute instead of 5-minute data) is billed as custom metrics: 7 metrics per instance, about $2.10 per instance per month at the first tier. Alarm details, including why new alarms sit in INSUFFICIENT_DATA, are in our alarm guide.

Worked pricing examples

  • A small app: 40 custom metrics, 2 dashboards, 15 alarms. Metrics (40 − 10 free) × $0.30 = $9; dashboards free; alarms (15 − 10) × $0.10 = $0.50. About $9.50 a month.
  • Detailed monitoring on 20 EC2 instances: 140 metrics × $0.30 = $42 a month, often for graphs nobody opens at 1-minute detail.
  • Jake's CustomerId dimension: thousands of metrics, hundreds to thousands of dollars depending on how many customers appear each hour. After the fix: 6 metrics, under $2.
  • A monitoring tool polling CloudWatch: 1,000 metrics every 5 minutes is 1,000 × 12 × 24 × 30 = 8.64 million metrics requested a month × $0.01 / 1,000 = $86.40 a month in GetMetricData alone; every minute, $432.
  • The same 1,000 metrics through a metric stream, one update a minute: 43.2 million updates × $0.003 / 1,000 = $129.60 plus Firehose, cheaper than polling at the same 1-minute freshness.

For a full estimate, list your metric names, multiply by the number of values of each dimension, and run the totals through the tiers. The AWS Pricing Calculator does the tier math for you once you know the count.

"CW:GMD-Metrics" on your bill: GetMetricData

The usage type CW:GMD-Metrics is GetMetricData: something reading metrics by API. Unlike most CloudWatch API calls, it has no free tier, and it is priced per metric requested, not per call (one call can ask for up to 500 metrics). Each request can include up to five statistics for one metric before it counts as another. Usual sources:

  • Third-party monitoring tools (observability platforms, Grafana) polling CloudWatch for every metric in the account, every minute.
  • Shared dashboards: rendering a shared dashboard calls GetMetricData (viewing your own in the console does not charge you).
  • Your own scripts or Lambda functions pulling metrics on a schedule.
  • Autoscaling tools outside AWS's own scaling, such as Kubernetes metric adapters.

To cut it: poll less often (5 minutes instead of 1 cuts it by five), poll only the namespaces and metrics you actually chart, or replace polling with a metric stream, which pushes updates to the tool through Firehose at a lower per-update price.

Where to change it depends on the tool. Most observability platforms have an AWS integration page with a polling interval and a list of namespaces or services to collect; uncheck the ones you never chart (many accounts collect every namespace by default). In Grafana, the CloudWatch data source queries on every dashboard refresh, so a wall screen refreshing every 10 seconds across 50 panels is a steady GetMetricData stream; set refresh to 1 or 5 minutes for anything that is not an incident screen.

Jake: "There's a second big line, GMD-Metrics. We don't even call that."

Ethan: "The monitoring tool does. Every metric, every minute. Either it polls less, or we stream."

Find what is costing you

  1. Cost Explorer: filter Service to CloudWatch and group by Usage type. CW:MetricMonitorUsage is metric storage (custom and detailed monitoring), CW:GMD-Metrics is GetMetricData, CW:Requests is other API calls, CW:AlarmMonitorUsage is alarms.
  2. Count your custom metrics by namespace: aws cloudwatch list-metrics --namespace "Shop/Checkout" --query "length(Metrics)", and repeat for CWAgent and any other namespace you own.
  3. Spot the high-cardinality dimension: list one metric name's dimensions and see which dimension has hundreds of values: aws cloudwatch list-metrics --namespace "Shop/Checkout" --metric-name OrdersPlaced --query "Metrics[].Dimensions[].Name" --output text.
  4. Find who calls GetMetricData: the AWS/Usage namespace shows CloudWatch API call counts by operation, and the tools you have connected to the account (and their polling settings) are the usual answer.
  5. Set a budget alert on CloudWatch spend so the next surprise is a day old, not a month old; our billing and budgets guide shows how.

Ten ways to cut CloudWatch metric costs

  • Remove high-cardinality dimensions (user ID, order ID, request ID, full URLs); keep them as EMF log fields.
  • Use EMF instead of PutMetricData in Lambda and containers: no API calls, one log line.
  • Batch PutMetricData: many metrics per call, and Values/Counts arrays for many observations.
  • Stop publishing unused metrics: billing stops in the hours they receive no data.
  • Turn off EC2 detailed monitoring where 5-minute data is enough.
  • Trim the CloudWatch agent config: fewer metrics, and drop InstanceId-style dimensions you never filter on.
  • Avoid high resolution unless an alarm needs sub-minute reaction.
  • Poll less, or stream, for external monitoring tools.
  • Delete dashboards and alarms nobody uses beyond the free allowance.
  • Aggregate in code: publish one "checkout time" metric with statistics, not a metric per page or per endpoint unless you alarm on each.

Seven custom metric mistakes, and the fix for each

  1. IDs as dimensions (user, order, session, request, container). Fix: log fields with EMF, searchable in Logs Insights.
  2. One PutMetricData call per event. Fix: batch up to 1,000 metrics per call, or use EMF and make no calls at all.
  3. Re-publishing free AWS metrics. Fix: use the AWS/ namespaces for Lambda, ALB, API Gateway and SQS numbers.
  4. High resolution by default. Fix: standard 1-minute resolution unless an alarm truly needs to react within seconds.
  5. Mixed units on one metric. Fix: one unit per metric, written into the code that publishes it.
  6. Sparse metrics with default missing-data handling. Fix: decide per alarm whether no data means fine or broken.
  7. Nobody owns the bill. Fix: a budget alert on CloudWatch spend, and a quarterly look at metrics per namespace with list-metrics.

Each of these has shown up on real bills, and none needs a new tool to fix; a code change or a setting is enough.

Metrics across accounts and Regions

If your workloads span several AWS accounts, you do not need to copy metrics around. CloudWatch cross-account observability links source accounts to a central monitoring account, where dashboards, alarms and Metrics Insights queries can read metrics from all of them. The sharing itself is not a separate line on the bill; the normal metric, alarm and API charges apply in the accounts where they happen, so it is the cheapest way to get one view of many accounts.

Metrics live in the Region where they are published. A dashboard can show widgets from several Regions side by side, but an alarm watches metrics in its own Region, so a service deployed in two Regions needs alarms in each. Global services report in one fixed Region (for example, CloudFront and billing metrics appear in US East), which is why a "missing" metric is sometimes just in a Region you did not look at.

Metrics are rarely the biggest line on an AWS bill, but they are one of the most surprising. Our list of 10 common AWS surprise charges covers the others, including logs that never expire.

The CloudWatch agent: memory and disk without a big bill

EC2 does not report memory or disk usage on its own, so most teams install the CloudWatch agent, and many then pay for far more metrics than they look at. A lean configuration collects only what you alarm on, and aggregates across instances instead of keeping one series per instance:

{
  "metrics": {
    "namespace": "CWAgent",
    "append_dimensions": {"AutoScalingGroupName": "${aws:AutoScalingGroupName}"},
    "aggregation_dimensions": [["AutoScalingGroupName"]],
    "metrics_collected": {
      "mem": {"measurement": ["mem_used_percent"], "metrics_collection_interval": 60},
      "disk": {"measurement": ["used_percent"], "resources": ["/"], "metrics_collection_interval": 60}
    }
  }
}

What each choice saves:

  • Two measurements, not twenty. The agent can collect dozens of CPU, disk, network and process figures; each is a custom metric per dimension combination. Memory used and root disk used cover most alarms.
  • One disk, not every mount. "resources": ["/"] stops the agent from creating a series for every mount point and temporary filesystem, which on container hosts can be dozens.
  • Group-level aggregation. aggregation_dimensions adds a series per Auto Scaling group, which is what you usually alarm on. If you also keep the per-instance InstanceId dimension, remember each instance adds its own metrics while it runs; proration keeps short-lived instances cheap, but a 50-instance fleet running all month is 50 times the per-instance count.
  • 60-second interval. Collecting every 10 seconds makes the data high resolution, which costs more to alarm on and is rarely needed for memory or disk.

For a fleet of 20 instances, the lean config above is 2 group-level metrics; the agent's "advanced" preset with per-instance dimensions can easily be several hundred. Same agent, same instances, a bill a hundred times larger.

Alarming on custom metrics without false alarms

Custom metrics behave differently from AWS's built-in ones in one important way: they only have data points when your code publishes them. An error counter that is only published when an error happens has no data at all on a good day, and an alarm on it sits in INSUFFICIENT_DATA or, worse, goes off when you least expect. Three settings fix it:

  1. Treat missing data on purpose. For error counts, set missing data to notBreaching: no data means no errors. For "heartbeat" metrics that should always arrive, set it to breaching, so silence itself raises the alarm.
  2. Publish zeros where it matters. Sending FailedPayments = 0 every minute makes graphs honest and alarms predictable, at the cost of a constant data stream (still one metric for billing).
  3. Use "M out of N" data points. Alarm when 3 of the last 5 one-minute periods breach, not on a single spike, so one slow request does not page anyone at night.

Pick the statistic deliberately too: Sum for counts (orders, errors), p95 or p99 for latency, Maximum for things like queue age. Averages hide the slow requests your customers actually notice. Our INSUFFICIENT_DATA guide covers the other reasons an alarm sits waiting.

Jake: "The failed-payments alarm fired at 3 a.m. with zero failures."

Ethan: "Missing data set to breaching on a metric that only exists when something fails. Not breaching for that one; breaching only for heartbeats."

PutMetricData limits, units and percentiles

The limits that shape how you publish:

  • Up to 1,000 metrics per PutMetricData call, with a 1 MB request size limit, so batching is cheap and easy.
  • Up to 150 values per metric entry in the Values/Counts arrays.
  • Up to 30 dimensions per metric.
  • Timestamps can be up to two weeks in the past and two hours in the future; older data points are rejected, which matters when you backfill.
  • Permissions: cloudwatch:PutMetricData does not support resource-level restrictions, but you can limit it to specific namespaces with the cloudwatch:namespace condition key, so a service can only write to its own namespace.

Units deserve care. CloudWatch keeps the unit you send with each data point, and statistics are worked out per unit, so a metric sometimes published in Milliseconds and sometimes in Seconds produces confusing graphs. Pick one unit per metric and stick to it.

Percentiles (p50, p95, p99) need the raw values. If you publish only a pre-aggregated statistic set (sum, count, minimum, maximum), CloudWatch cannot work out percentiles from it. The Values/Counts form keeps percentiles available while still batching many observations per call, which is the best of both.

OpenTelemetry, Prometheus and very high cardinality

Many teams now instrument with OpenTelemetry or already run Prometheus. Both can feed CloudWatch: the AWS Distro for OpenTelemetry collector has an exporter that writes metrics as EMF into CloudWatch Logs, and Container Insights collects cluster metrics on ECS and EKS. The billing rule does not change on the way in: every unique set of labels becomes a CloudWatch metric, so a Prometheus-style metric with a path or pod label arrives as hundreds or thousands of custom metrics.

When high cardinality is the point (per-pod, per-endpoint, per-tenant series you really do query), CloudWatch's per-metric pricing is the wrong shape. Amazon Managed Service for Prometheus prices by samples ingested and stored instead of by unique series per month, which can be far cheaper for thousands of series that each report infrequently, and far dearer for a few series reporting every second. Price both with your real numbers before choosing: count series, multiply by samples per month, and compare.

For most small and mid-sized apps, the simpler answer still holds: keep the high-cardinality detail in logs, keep CloudWatch metrics few, and reach for a Prometheus store only when a real dashboard needs thousands of live series.

Anomaly detection and composite alarms on custom metrics

Fixed thresholds work badly for metrics with a daily rhythm, like orders: 20 an hour is alarming at noon and normal at 3 a.m. An anomaly detection alarm learns the metric's normal pattern (including daily and weekly cycles) and alarms when the value leaves the expected band. It is priced as three standard alarm metrics, about $0.30 a month, because it tracks the value and the band's upper and lower edges. Give it a couple of weeks of history before trusting it, and exclude known unusual periods (a sale, an outage) so they do not teach it the wrong normal.

Composite alarms ($0.50 a month) combine others with AND and OR, which cuts noise: page someone only when error rate is high AND orders have dropped, rather than for either alone. For a small team, one composite alarm per service that pages, with the individual alarms feeding it quietly, is often the difference between alerts people trust and alerts people mute.

A worked monthly budget for a small team

To make the numbers concrete, here is a sensible monitoring setup for a five-service app in two environments, priced at the US East rates above:

  • Custom metrics: 5 per service, 2 dimension values (environment) = 50 metrics; minus 10 free = 40 × $0.30 = $12.00.
  • CloudWatch agent: memory and disk aggregated by Auto Scaling group, 5 groups in production = 10 metrics × $0.30 = $3.00.
  • Alarms: 25 standard alarms (10 free) = 15 × $0.10 = $1.50, plus 5 composite alarms × $0.50 = $2.50, plus 3 anomaly detection alarms × $0.30 = $0.90: $4.90.
  • Dashboards: 4, with 3 free = $3.00.
  • External tool polling: none; the team uses CloudWatch dashboards. $0.

Total: about $23 a month for metrics and alarms, before log ingestion. The same app with a per-customer dimension, detailed monitoring on every instance, and a tool polling every metric every minute could easily cost fifty times as much for no extra insight. The difference is entirely design, not traffic.

Metrics Insights: query metrics like a table

Once you have many metrics, finding the interesting ones by clicking gets slow. CloudWatch Metrics Insights lets you query them with a SQL-like language, in the console, in dashboards and in alarms:

SELECT AVG(CPUUtilization)
FROM SCHEMA("AWS/EC2", InstanceId)
GROUP BY InstanceId
ORDER BY AVG() DESC
LIMIT 10

That returns the ten busiest instances right now, without a dashboard per instance. The same works on your own namespaces: the slowest checkout endpoints, the queues with the most messages, the services with the most errors. Queries run through GetMetricData, so they are billed by the number of metrics they analyze; a query over a namespace with thousands of series costs more than one over a few dozen, which is another reason to keep cardinality low. An alarm built on a Metrics Insights query can watch a whole fleet with one alarm, instead of one alarm per instance.

Reading metrics back: get-metric-statistics vs get-metric-data

Three ways to get metric data out of CloudWatch, priced differently:

MethodMetrics per callPricedBest for
get-metric-statistics1Per API request (free tier applies)Quick checks and small scripts
get-metric-dataUp to 500, with math and Metrics Insights$0.01 per 1,000 metrics requested, no free tierDashboards and tools that need many metrics at once
Metric streamContinuous push, by namespace filter$0.003 per 1,000 updates, plus FirehoseExternal monitoring platforms that want everything, all the time

Rule of thumb: a person looking at a graph, use the console (free to view your own dashboards); a script checking a handful of values now and then, get-metric-statistics; a tool that wants thousands of metrics every minute, a stream. A quick check from the CLI:

aws cloudwatch get-metric-statistics --namespace "Shop/Checkout" --metric-name OrdersPlaced \
  --dimensions Name=Environment,Value=prod --statistics Sum --period 3600 \
  --start-time 2026-10-19T00:00:00Z --end-time 2026-10-20T00:00:00Z

In boto3, get_metric_data pages through results with a NextToken; the paginator does that for you. Ask for the period you actually need: an hourly sum over a week is far fewer data points, and far quicker, than one-minute data for the same week.

Frequently asked questions

How much does a CloudWatch custom metric cost?

$0.30 per metric per month for the first 10,000 in US East, then $0.10 and $0.05 at higher volumes; the first 10 are free.

How are CloudWatch metrics counted?

Each unique combination of namespace, metric name and dimension values is one billable metric.

How do I create a custom metric in CloudWatch?

Publish data with aws cloudwatch put-metric-data, boto3 put_metric_data, Embedded Metric Format logs, the CloudWatch agent or a log metric filter.

What is CW:GMD-Metrics on my AWS bill?

GetMetricData usage: metrics read by API, usually by monitoring tools or shared dashboards, at $0.01 per 1,000 metrics requested.

Is GetMetricData included in the free tier?

No. GetMetricData is always charged; the 1 million free API requests do not cover it.

Are custom metrics charged if I stop sending data?

No. Charges are prorated hourly and only apply in hours when the metric receives data.

Can I delete a CloudWatch metric?

No. Stop publishing to it; it stops being billed and its data expires on the normal retention schedule.

What is Embedded Metric Format?

A JSON log format with an _aws block from which CloudWatch Logs extracts metrics, avoiding PutMetricData calls.

Why is my CloudWatch bill so high?

Usually high-cardinality dimensions creating thousands of metrics, GetMetricData polling, detailed monitoring or log ingestion.

How much does EC2 detailed monitoring cost?

It is billed as custom metrics: 7 metrics per instance, about $2.10 per instance per month at the first tier.

How much do CloudWatch dashboards cost?

$3.00 per dashboard per month after 3 free dashboards with up to 50 metrics each.

How much do CloudWatch alarms cost?

$0.10 per standard alarm metric per month, $0.30 for high resolution and $0.50 for composite alarms; 10 standard alarm metrics are free.

Is a metric stream cheaper than polling?

At the same freshness, usually yes: $0.003 per 1,000 updates versus $0.01 per 1,000 metrics requested by GetMetricData.

How many dimensions can a CloudWatch metric have?

Up to 30, but every distinct combination of values is a separate billable metric.

How long does CloudWatch keep metric data?

1-minute data for 15 days, 5-minute for 63 days, hourly for 455 days; sub-minute data for 3 hours.

What is the difference between get-metric-statistics and get-metric-data?

get-metric-statistics reads one metric per request at API-request pricing; get-metric-data reads up to 500 per call at per-metric pricing.

Are CloudWatch agent metrics custom metrics?

Yes. Memory, disk and other agent metrics are billed as custom metrics, multiplied by their dimensions.

How do I find which namespace costs the most?

Group CloudWatch costs by usage type in Cost Explorer, then count metrics per namespace with list-metrics.

How do I publish custom metrics from Lambda?

Use Embedded Metric Format, most easily with Powertools for AWS Lambda's Metrics utility, so the metric comes from a log line with no API call.

How many metrics can one PutMetricData call send?

Up to 1,000 metrics per call, within a 1 MB request, and up to 150 values per metric entry.

Why does my custom metric alarm show INSUFFICIENT_DATA?

The metric only has data when your code publishes it; set missing data treatment, or publish zeros on quiet periods.

Can I get percentiles for a custom metric?

Yes, if you publish raw values (or Values and Counts arrays); a pre-aggregated statistic set cannot produce percentiles.

How do I reduce CloudWatch agent metric costs?

Collect only the measurements you alarm on, limit disk resources to the mounts you need, and aggregate by Auto Scaling group.

What is CloudWatch Metrics Insights?

A SQL-like query language over your metrics, for finding top resources and building fleet-wide alarms; billed through GetMetricData.

Why is my new custom metric not showing in CloudWatch?

New metrics take a few minutes to appear in list-metrics; also check the Region, the namespace spelling, the graph's period and statistic, and that the publish call did not fail.

How do I publish a custom metric from Node.js?

Use the AWS SDK v3 CloudWatchClient with PutMetricDataCommand, batching several metrics in one call.

What is the cheapest way to send custom metrics?

Embedded Metric Format from your logs, with few dimensions; it needs no PutMetricData calls and you pay only for the metrics and the log ingestion.

Are AWS service metrics free in CloudWatch?

Yes. Basic metrics in the AWS namespaces, such as Lambda, ALB, API Gateway and SQS, are free; you pay for alarms on them and for detailed monitoring.

Can I see metrics from several AWS accounts in one place?

Yes, with CloudWatch cross-account observability, which links source accounts to a monitoring account for dashboards, alarms and queries.

Why can't I find a CloudWatch metric?

It may be in another Region (global services such as CloudFront and billing report in US East), or nothing has published to it within the retention period.

Should I use a metric filter or EMF?

A metric filter for logs you do not control; EMF for your own code, where you choose the metric when you write the log line.

Do metric filters work on old logs?

No. A metric filter only counts log events that arrive after it is created; use Logs Insights for past logs.

How much does a CloudWatch anomaly detection alarm cost?

It is billed as three standard alarm metrics, about $0.30 a month in US East.

Is Amazon Managed Service for Prometheus cheaper than CloudWatch metrics?

For thousands of high-cardinality series reporting infrequently it can be; it prices by samples, not unique series, so compare with your real numbers.

How many custom metrics does a small app need?

Often five per service: requests, errors, duration, one business number and one saturation measure, with environment and service as dimensions.

Can I restrict which namespace an app can write metrics to?

Yes, with the cloudwatch:namespace condition key on the cloudwatch:PutMetricData permission.

For readers preparing for an AWS certification

We have been covering AWS certifications alongside our fixes, so here is a short extra for readers studying for one. If you only came for the fix, you already have it; feel free to skip this part.

Exams that test this topic: CloudOps Engineer – Associate (SOA-C03) • Developer – Associate (DVA-C03 from December 1, 2026) • Cloud Practitioner.

Here are the exam-style questions this topic tends to raise, with the reasoning you need to answer them:

1. An application must publish a business metric such as orders placed to CloudWatch. Which API is used?

PutMetricData (or Embedded Metric Format logs).

2. Which agent collects memory and disk utilization from EC2 instances into CloudWatch?

The CloudWatch agent.

3. What makes CloudWatch custom metric costs grow unexpectedly?

High-cardinality dimensions: each unique combination of dimension values is a separate metric.

4. How can a Lambda function emit custom metrics without calling PutMetricData?

By writing logs in CloudWatch Embedded Metric Format (EMF).

5. How long does CloudWatch keep 1-minute metric data?

15 days (then aggregated to 5-minute and hourly data).

6. Which feature continuously sends CloudWatch metrics to a third-party destination through Firehose?

CloudWatch metric streams.

Exam codes and dates change often. Our AWS certification changes page keeps track of what is current.

πŸ“š ALSO READ

Where to go next, from log groups to cross-AZ costs:

📌 Bookmark this; the pricing tables and the ten fixes are the parts you will come back for.

The checkout service now publishes six metrics through EMF, with CustomerId and OrderId as log fields that Logs Insights can search in seconds. The monitoring tool polls every five minutes instead of every minute. The CloudWatch line went from several hundred dollars to under twenty, and Jake can still look up any customer's checkout, just in the logs instead of a graph.

The team also added two habits. Every pull request that adds a metric now says which alarm or dashboard will use it, and once a quarter Ethan runs list-metrics per namespace and deletes the publishing code for anything nobody has looked at. The metric count has stayed flat while the app has grown, which is exactly what a healthy metrics bill looks like.

📌 If you keep one line from this page

A CloudWatch custom metric costs $0.30 a month (first 10,000), but every unique dimension combination is its own metric and GetMetricData reads cost $0.01 per 1,000; keep IDs out of dimensions, publish with EMF, and poll less or stream.

Cost Explorer by usage type · list-metrics to count · detailed monitoring = 7 metrics per instance.

Revision note. Written October 20, 2026, with US East prices of that day.

Related