Skip to content

Link

Source: src/AWS/OAM/Link.ts

A CloudWatch cross-account observability link — created in a source account, it attaches to a monitoring-account Sink and shares the selected telemetry types (metrics, log groups, traces, Application Signals) with that account.

The sink must live in a different account and its sink policy must authorize this account to link.

Share metrics and logs with a monitoring account

import * as OAM from "alchemy/AWS/OAM";
const link = yield* OAM.Link("ToMonitoring", {
labelTemplate: "$AccountName",
resourceTypes: ["AWS::CloudWatch::Metric", "AWS::Logs::LogGroup"],
sinkIdentifier:
"arn:aws:oam:us-west-2:111122223333:sink/1c72e9ec-4d4a-4e...",
});

Filter what is shared

const link = yield* OAM.Link("FilteredLink", {
labelTemplate: "$AccountName",
resourceTypes: ["AWS::CloudWatch::Metric", "AWS::Logs::LogGroup"],
sinkIdentifier: sinkArn,
linkConfiguration: {
logGroupConfiguration: { filter: "LogGroupName LIKE 'aws/lambda/%'" },
metricConfiguration: { filter: "Namespace NOT LIKE 'AWS/%'" },
},
});