Skill 4.2.3
Implement code that emits custom metrics
Key Concepts
Using the SDK, code calls PutMetricData, ideally batching several values per call. Using the embedded metric format, code writes structured JSON log lines that CloudWatch turns into metrics, which is preferred in Lambda because it adds no API calls. Powertools for AWS Lambda provides a Metrics utility that buffers metrics and flushes them as EMF at the end of each invocation.
Metrics should use a clear namespace, meaningful dimensions such as Service and Environment, and correct units. They can then drive alarms, dashboards and Auto Scaling policies.