识别目标组中的AWS不正常主机

时间:2018-09-13 10:02:58

标签: amazon-web-services amazon-ec2

我在AWS ALB后面运行了多个targetGroup。此外,我设置了cloudwatch警报来监视这些目标组的运行状况。每当该组中的目标生成不健康主机警报时,AWS都会发送电子邮件提醒我该组中的目标遭受了不健康。但是,警报和电子邮件不会通知我该目标组的哪个实例不正常。

是否有一种方法或解决方案来实施并找出导致该问题的目标人员是谁?

1 个答案:

答案 0 :(得分:0)

# Trigger the lambda function when an EC2 instance is terminated
resource "aws_cloudwatch_event_rule" "instance_terminated" {
  name = "ChefCleanup-InstanceTerminated-rule"
  description = "Capture each EC2 instance termination"
  event_pattern = <<PATTERN
  {
    "source": [ "aws.ec2" ],
    "detail-type": [ "EC2 Instance State-change Notification" ],
    "detail": {
      "state": [ "terminated" ]
    }
  }
PATTERN
}

# Set event target to call the lambda
resource "aws_cloudwatch_event_target" "instance_terminated" {
  rule      = "${aws_cloudwatch_event_rule.instance_terminated.name}"
  target_id = "chef-cleanup-lambda"
  arn      = "${aws_lambda_function.chef_cleanup.arn}"
}