OpsCanary
Back to daily brief
awsobservabilityPractitioner

Unlocking Observability: Embedding Metrics in AWS Logs

5 min read AWS DocsApr 23, 2026
PractitionerHands-on experience recommended

In today's cloud-native environments, observability is crucial for maintaining system health and performance. Traditional logging often leaves you with a wealth of data but little actionable insight. By embedding metrics directly within your logs, you can bridge this gap, allowing for more granular monitoring and faster incident response.

The CloudWatch embedded metric format enables you to generate custom metrics asynchronously in the form of logs written to CloudWatch Logs. This means you can embed custom metrics alongside detailed log event data. CloudWatch automatically extracts these metrics, allowing you to visualize and set alarms on them. To make this work, ensure you have the necessary permission: logs:PutLogEvents. Interestingly, you don’t need the cloudwatch:PutMetricData permission, simplifying your permission management.

However, be cautious with your metric extraction configuration. It directly impacts your custom metric usage and billing. If you inadvertently create metrics based on high-cardinality dimensions, such as requestId, you could end up with a multitude of custom metrics—one for each unique dimension combination. This can lead to unexpected costs and complexity in your monitoring setup.

Key takeaways

  • Use the CloudWatch embedded metric format to generate custom metrics asynchronously.
  • Ensure you have logs:PutLogEvents permission to embed metrics in logs.
  • Monitor your metric extraction configuration to avoid high costs from high-cardinality dimensions.
  • Visualize and alarm on embedded metrics for real-time incident detection.

Why it matters

Embedding metrics within logs allows for more effective monitoring and quicker incident response, which is essential in maintaining high availability and performance in production environments.

Code examples

plaintext
logs:PutLogEvents
plaintext
cloudwatch:PutMetricData

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.