Closed marcogrcr closed 10 months ago
I debated internally whether customTags
+ PredefinedCustomTags
was the most appropriate way to implement this, or whether I should've added a new field to:
I ultimately decided to go with the former because the field would also have to be added to:
And it would've had to be populated on every addSomeAlarm
method. While this would be mostly mitigated by the usage of the spread operator in the lib/common/monitoring/alarms/
factory implementations, for example:
Any user-defined subclass of MonitoringFacade
that does not use the spread operator, would miss propagating the property accordingly. Additionally, using customTags
makes it easy later to query all the appropriate alarms for creating the health checks as follows:
monitoring.createdAlarmsWithTag(PredefinedCustomTags.ROUTE_53_HEALTH_CHECK);
OK, I've taken your suggestion and added a new implementation. I've also updated https://github.com/cdklabs/cdk-monitoring-constructs/pull/411#issue-1850911095 to reflect the change. Hope this is in line with what you had in mind!
WHAT?
Introduce
interface IMetricAdjuster
which allows to adjust a metric beforeAlarmFactory
creates an alarm from it.Additionally created three implementations of
IMetricAdjuster
:DefaultMetricAdjuster
: Contains the metric adjustment logic which used to be inlined in theAlarmFactory.addAlarm()
method.CompositeMetricAdjuster
: Allows to apply a collection ofIMetricAdjuster
instances, one after the other.Route53HealthCheckMetricAdjuster
: Validates a metric's configuration and transforms it so that it can be used to create CloudWatch alarms compatible with Route53 Health Checks.WHY?
Route53 Health Checks have strict requirements about which CloudWatch alarms can be used. By default, alarms created by
MonitoringFacade
use metrics with thelabel
property set which results in alarms that are incompatible with Route53 Health Checks. This commit introdues an opt-inRoute53HealthCheckMetricAdjuster
class that allows users to mark alarms to be suitable for Route53 Health Checks.HOW?
npx yarn build
succeeds all the way topackage:js
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license