Custom Metrics, Dashboards & Best Practices
Track business numbers, build a dashboard, and avoid surprise bills.
1 min read
AWS metrics tell you about infrastructure. Custom metrics tell you about your business: notes summarized, sign-ups, payment failures.
Try it
metrics.py
import boto3
cloudwatch = boto3.client("cloudwatch")
cloudwatch.put_metric_data(
Namespace="NoteSnap",
MetricData=[{
"MetricName": "NotesSummarized",
"Dimensions": [{"Name": "Plan", "Value": "free"}],
"Value": 1,
"Unit": "Count",
}],
)Tip
In Lambda, the Embedded Metric Format (EMF) creates metrics from specially formatted log lines, with no extra API calls. Powertools for AWS Lambda makes this a one-liner.
A good starter dashboard
For each service, chart traffic, errors, latency (p99), and saturation (throttles, queue depth, CPU). Add one row of business metrics on top.
Best practices
- Set log retention on every log group (e.g. 30 days), and export to S3 if you must keep logs longer.
- Alarm on symptoms users feel: error rate, p99 latency, and DLQ depth, not every CPU blip.
- Avoid high-cardinality dimensions such as user ID or request ID. Each unique combination is a separate billed metric.
- Use X-Ray / Application Signals for distributed tracing across services.
- Send alarms somewhere people actually look: chat, on-call tools, or email for low-priority alerts.
Key takeaways
- Publish custom business metrics with put_metric_data or EMF.
- Dashboards: traffic, errors, latency, saturation, plus business metrics.
- Set retention, alarm on user-facing symptoms, and avoid high-cardinality dimensions.
Check your understanding
Pick an answer to see the explanation.
1. Why avoid using userId as a metric dimension?