Sub topic 17
Cross-account and cross-region observability
This chapter assumes you can create alarms and dashboards, know what log groups are, and have more than one AWS account or region to watch. By default, CloudWatch data stays in the account and region that produced it. Cross-account observability lets one monitoring account view that data without switching accounts.
The sink and link model
CloudWatch uses Observability Access Manager (OAM) for this. It has two resources:
- A sink lives in the monitoring account. It is the target that receives shared data.
- A link lives in a source account. It connects that account to a sink and names the data types to share.
Sharing is opt-in on both sides. The monitoring account decides who may link. The source account decides what to share.
Set up the monitoring account
Create the sink, then attach a policy that says which accounts may link.
aws oam create-sink --name central-monitoring{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "AWS": "*" },
"Action": ["oam:CreateLink", "oam:UpdateLink"],
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": {
"oam:ResourceTypes": ["AWS::CloudWatch::Metric", "AWS::Logs::LogGroup"]
},
"StringEquals": { "aws:PrincipalOrgID": "o-exampleorgid" }
}
}
]
}Save the policy as sink-policy.json and apply it, using the sink ARN returned by the first command:
aws oam put-sink-policy \
--sink-identifier arn:aws:oam:us-east-1:999999999999:sink/EXAMPLE-ID \
--policy file://sink-policy.jsonThe aws:PrincipalOrgID condition limits linking to accounts in your AWS Organization. Without a condition like this, the "*" principal lets any account link.
Link a source account
Run this in each source account and each region you want to share:
aws oam create-link \
--label-template '$AccountName' \
--resource-types AWS::CloudWatch::Metric AWS::Logs::LogGroup \
--sink-identifier arn:aws:oam:us-east-1:999999999999:sink/EXAMPLE-IDThe label template names the source in the monitoring account's console. Supported resource types also include X-Ray traces and Application Insights applications.
What you can do afterward
In the monitoring account you can:
- Add metrics from linked accounts and regions to a single dashboard widget.
- Run Logs Insights queries across log groups in several accounts.
- Create alarms on shared metrics.
Linked accounts show up in the console's account selector, so you do not need to assume roles to look around.
Common errors
- Region mismatch. A link is created in one source region. To share a second region, create another link there.
- Wrong sink region. Sinks are regional resources, so use the sink ARN from the region you chose for monitoring.
- Missing resource type. If a policy lists only metrics, a link that also requests log groups is rejected.
- Cost surprises. The first link's metrics and logs sharing is free for the monitoring account, but extra links to the same source account can be billed. Check current pricing before rolling out widely.
Exercise
A source account created a link, but its CloudWatch metrics from eu-west-1 do not appear in the monitoring account. The link was created in us-east-1. What is the likely cause and fix?
Show answer
Links are per source region. The link in us-east-1 shares only us-east-1 data. Create another link in eu-west-1 that points to the same sink ARN.