Skip to main content
Welcome. In this lesson you’ll learn how to publish custom metrics to Amazon CloudWatch. CloudWatch exposes many built-in metrics for AWS services, but application-specific measurements (for example, the number of orders processed) require publishing custom metrics. We’ll use CloudShell (or any AWS CLI–enabled environment) to send a metric and then verify it in the CloudWatch console. Prerequisites Step 1 — Prepare your terminal Clear your terminal and compose the AWS CLI command to publish metric data. The API operation is put-metric-data (see the PutMetricData API docs: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricData.html). You must specify a namespace, metric name, value, and (optionally) a unit and dimensions. Example command:
Sample terminal interaction:
CLI flags reference Notes about best practices and important behaviors
  • --namespace groups related metrics together. Choose consistent, descriptive namespaces (e.g., your application name or team).
  • Metric names and namespaces are case-sensitive.
  • Attach --dimensions such as Name=environment,Value=prod or Name=service,Value=checkout to enable finer-grained filtering and aggregation.
  • Use --storage-resolution 1 to publish high-resolution (1-second) metrics when you need sub-minute granularity.
  • Units are optional but recommended to make metrics easier to interpret and to avoid unit-mismatch issues when creating alarms.
Verification — Check CloudWatch console Give CloudWatch a few seconds (typically under a minute) to ingest the data. Then open the CloudWatch console and navigate to Metrics → All metrics. You should see your custom namespace (for example, MyApplication) and the metric OrdersProcessed within it. If you didn’t publish dimensions, the metric will appear without them.
A screenshot of the AWS CloudWatch Metrics console showing an empty "Untitled graph" and time-range controls. Below the graph is a metric list that includes "OrdersProcessed" with no alarms.
Best practices: Use consistent namespaces and metric names. Attach dimensions (for example, environment=prod, service=checkout) to enable finer-grained filtering, aggregation, and alarm targeting.
What you can do next
  • Add the metric to dashboards for continuous visibility.
  • Create CloudWatch alarms on thresholds, anomalies, or rate-of-change.
  • Aggregate metrics by dimension, statistic (Sum, Average), and period to drive alerts and automated remediation.
References This is how you publish and verify a custom metric in CloudWatch when built-in AWS metrics don’t cover your application’s needs.

Watch Video