CloudWatch via SDK Best Practices
This is the checklist to run before shipping a CloudWatch-based observability setup beyond the Core section's single metric and alarm.
Busca en todas las páginas de la documentación
This is the checklist to run before shipping a CloudWatch-based observability setup beyond the Core section's single metric and alarm.
Each item is a rule stated positively, with a one-line rationale. The groups run in the same order this section covers: metrics, EMF, logs, alarms, and dashboards.
PutMetricData accepts up to 1,000 items per call; batching cuts request count and cost versus one call per metric.None, making graphs and alarms harder to read correctly._aws.CloudWatchMetrics envelope. A JSON log without it is just a log line - no metric gets extracted.Dimensions arrays must reference keys that actually exist alongside the metric values.PutEmbeddedMetric operation - it rides on PutLogEvents or plain stdout in Lambda.startTime/endTime window over a busy log group risks hitting the per-query scan limit.limit in the query string. Without one, fields and stats queries can return far more rows than you need.StopQuery on anything stuck or unexpectedly expensive.fields/filter/stats/sort is a distinct syntax passed as a plain string - there is no field-by-field query builder to fight.logGroupNames accepts more than one group per query when a request fans out across services.ANOMALY_DETECTION_BAND stays meaningful across traffic levels.ALARM(a) AND ALARM(b)) before notifying anyone.INSUFFICIENT_DATA for roughly the first two weeks, and don't page on it during that window.notBreaching, breaching, or ignore based on what missing data should mean for that specific alarm.NOT in a composite AlarmRule instead of disabling alarms manually.PutDashboard always replaces the full layout for that name.PutDashboard call.High-cardinality custom metrics via raw PutMetricData dimensions. A per-customer or per-request-id dimension multiplies billed metrics fast - move that data to EMF instead.
Raw counts scale with traffic, so a busy period looks the same as a broken one. A rate, percentage, or anomaly band stays meaningful regardless of traffic level, giving a stabler signal.
Narrow the time range, always add a limit, and cancel anything unexpectedly long-running with StopQuery instead of letting it scan to its limit.
No, they sit on top of ordinary alarms, combining their states with boolean logic. You still need the underlying PutMetricAlarm alarms to exist first.
About two weeks, long enough to learn daily and weekly seasonality. Treat earlier INSUFFICIENT_DATA states as expected, not a bug.
For a single, rarely-changed dashboard, that's fine. Once you need the same layout across environments or want it regenerated automatically, move to code-generated PutDashboard JSON and treat it as the source of truth.
Not universally - it's specifically cheaper at high cardinality, since it rides on log ingestion instead of multiplying billed metrics per dimension value. Low-cardinality core metrics often still fit direct PutMetricData well.
Stack versions: This page was written for boto3 1.43.x (Python 3.10+) and the AWS SDK for JavaScript v3 (Node.js 18+).
Revisado por Chris St. John·Última actualización: 25 jul 2026