The MonitoringFacade is the main entrypoint for the library. You create an instance of it within a CDK stack (or as a nested stack) and then chain methods to define your monitors.
Important: Do NOT import anything from the /dist/lib package, as it is unsupported and subject to breaking changes.
Common methods include .monitorLambdaFunction(), .monitorDynamoTable(), .monitorCustom(), and UI methods like .addLargeHeader() to organize your dashboard.
// This could be in the same stack as your resources, as a nested stack, or a separate stack
export class MonitoringStack extends DeploymentStack {
constructor(parent: App, name: string, props: MonitoringStackProps) {
super(parent, name, props);
const monitoring = new MonitoringFacade(this, "Monitoring", {
metricFactoryDefaults: { /* ... */ },
alarmFactoryDefaults: { /* ... */ },
dashboardFactory: { /* ... */ },
});
// Monitor your resources using method chaining
monitoring
.addLargeHeader("Storage")
.monitorDynamoTable({ /* ... */ })
.monitorLambdaFunction({ /* ... */ })
.monitorCustom({ /* ... */ });
}
}