ECS部署改变目标群体——如何维护依赖于目标群体的告警?
ECS deployment changes target group - how to maintain alarms that depend on target group?
我有一个工作负载 运行 作为附加到目标组的 ECS 服务。然后我有一个警报监视目标组的实例计数 (HealthyHostCount)。我想使用 2 个目标组实施 blue/green 部署,但似乎因为警报监视特定目标组的值,所以它需要在每次部署时与实际部署分开更新。
这看起来很脆弱,并且会有更好的方法来做到这一点(例如,在部署之后,如果我们有一个更新警报目标组的脚本,它可能会失败),但我看不到更好的方法.有明显更简单的解决方案吗?
与其监控您拥有所需数量的健康目标,不如监控您没有不健康的目标。
您的 ECS 服务将负责管理您想要的计数,而且您可能希望扩展该服务,因此我认为 UnHealthyHostCount 是更好的警报指标。
如下为每个目标组创建一个警报。
这些不会在正常 ECS blue/green 部署之间触发,只有在注册目标未通过健康检查时才会触发。您需要相应地调整目标组的健康检查设置和 ECS 服务的 HealthCheckGracePeriodSeconds 设置。
BlueUnHealthyHostCountAlarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmDescription: 'Alarms when there is any unhealthy target'
Namespace: 'AWS/ApplicationELB'
MetricName: UnHealthyHostCount
Statistic: Maximum
Period: 60
EvaluationPeriods: 2
ComparisonOperator: GreaterThanThreshold
Threshold: 1
AlarmActions:
- Topic
Dimensions:
- Name: LoadBalancer
Value: AlbFullName
- Name: TargetGroup
Value: BlueTargetGroup
GreenUnHealthyHostCountAlarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmDescription: 'Alarms when there is any unhealthy target'
Namespace: 'AWS/ApplicationELB'
MetricName: UnHealthyHostCount
Statistic: Maximum
Period: 60
EvaluationPeriods: 2
ComparisonOperator: GreaterThanThreshold
Threshold: 1
AlarmActions:
- Topic
Dimensions:
- Name: LoadBalancer
Value: AlbFullName
- Name: TargetGroup
Value: GreenTargetGroup
我有一个工作负载 运行 作为附加到目标组的 ECS 服务。然后我有一个警报监视目标组的实例计数 (HealthyHostCount)。我想使用 2 个目标组实施 blue/green 部署,但似乎因为警报监视特定目标组的值,所以它需要在每次部署时与实际部署分开更新。
这看起来很脆弱,并且会有更好的方法来做到这一点(例如,在部署之后,如果我们有一个更新警报目标组的脚本,它可能会失败),但我看不到更好的方法.有明显更简单的解决方案吗?
与其监控您拥有所需数量的健康目标,不如监控您没有不健康的目标。 您的 ECS 服务将负责管理您想要的计数,而且您可能希望扩展该服务,因此我认为 UnHealthyHostCount 是更好的警报指标。
如下为每个目标组创建一个警报。
这些不会在正常 ECS blue/green 部署之间触发,只有在注册目标未通过健康检查时才会触发。您需要相应地调整目标组的健康检查设置和 ECS 服务的 HealthCheckGracePeriodSeconds 设置。
BlueUnHealthyHostCountAlarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmDescription: 'Alarms when there is any unhealthy target'
Namespace: 'AWS/ApplicationELB'
MetricName: UnHealthyHostCount
Statistic: Maximum
Period: 60
EvaluationPeriods: 2
ComparisonOperator: GreaterThanThreshold
Threshold: 1
AlarmActions:
- Topic
Dimensions:
- Name: LoadBalancer
Value: AlbFullName
- Name: TargetGroup
Value: BlueTargetGroup
GreenUnHealthyHostCountAlarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmDescription: 'Alarms when there is any unhealthy target'
Namespace: 'AWS/ApplicationELB'
MetricName: UnHealthyHostCount
Statistic: Maximum
Period: 60
EvaluationPeriods: 2
ComparisonOperator: GreaterThanThreshold
Threshold: 1
AlarmActions:
- Topic
Dimensions:
- Name: LoadBalancer
Value: AlbFullName
- Name: TargetGroup
Value: GreenTargetGroup