Reputation: 11
Can someone provide some basic setup on how to create a simple cloudwatch alarm, alert, metric using Cdk?
I am extremely new to CDK -and using typescript. I just need some startup guidance, where to create these ts file- I am abit confgused
Upvotes: 1
Views: 4681
Reputation: 59
new cloudwatch.Alarm(this, "Errors", {
alarmName: "AlertForEDITest",
metric: new cloudwatch.Metric({
"metricName": "NDMEDIMetricTest",
"namespace": "NDMItemsTest",
"period": Duration.minutes(1),
"unit": cloudwatch.Unit.COUNT,
"statistic": cloudwatch.Statistic.SUM
}),
threshold: 1,
comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD,
treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
evaluationPeriods: 30
});
Upvotes: 0
Reputation: 327
new Alarm(this, "Errors", {
alarmName: "MyTestAlarm",
metric: new Metric({
"metricName": "MyTestMetric",
"namespace": "SampleApplicationName",
"period": Duration.minutes(1),
"unit": Unit.COUNT,
"statistic": Statistic.SUM
}),
threshold: 0,
comparisonOperator: ComparisonOperator.GREATER_THAN_THRESHOLD,
treatMissingData: TreatMissingData.NOT_BREACHING,
evaluationPeriods: 3
});
Please refer to the Cloudwatch CDK Typescript overview for more depth and understanding.
Also, here's a GitHub repository with CDK Typescript sample apps. These samples will help you with basic CDK app setup.
Edit
Cloudwatch documentation is a good place to understand the basic concepts.
Upvotes: 1