【问题标题】:specify serverId in cloud watch alarms在 cloudwatch 警报中指定服务器 ID
【发布时间】:2022-07-27 14:47:29
【问题描述】:

我正在尝试为 aws t 创建警报传输家庭服务器\'as Bytes公制。如果我单击指标名称附近的警报按钮:

我被引导到警报创建页面,其中已经指定了命名空间、指标名称和服务器 ID。但是,当我尝试通过 terraform 创建警报时,我看不到任何可以指定 serverId 的参数。那么如何将特定服务器链接到此警报?

resource \"aws_cloudwatch_metric_alarm\" \"foobar\" {
  alarm_name                = \"test-alarm\"
  comparison_operator       = \"LessThanOrEqualToThreshold\"
  evaluation_periods        = \"2\"
  metric_name               = \"BytesIn\"
  namespace                 = \"AWS/Transfer\"
  period                    = \"3600\"
  statistic                 = \"Sum\"
  threshold                 = \"0\"
  alarm_description         = \"This metric monitors ftp connection\"
  insufficient_data_actions = []
}
  • ServerId 是否有值,即它是硬编码值还是有一部分代码用于创建服务器?

标签: amazon-web-services terraform amazon-cloudwatch terraform-provider-aws aws-transfer-family


【解决方案1】:

根据用于监控 Transfer 系列 [1] 的 AWS 文档,ServerId 字段是所谓的方面.由于在 Terraform 文档中没有 Transfer 系列的示例,因此可能有点难以理解需要做什么,但还有其他示例 dimensions,例如,对于 NLB [2]:

  dimensions = {
    TargetGroup  = aws_lb_target_group.lb-tg.arn_suffix
    LoadBalancer = aws_lb.lb.arn_suffix
  }

由于您已经提供了大部分要求,因此唯一缺少的是 dimensions 块:

resource "aws_cloudwatch_metric_alarm" "foobar" {
  alarm_name                = "test-alarm"
  comparison_operator       = "LessThanOrEqualToThreshold"
  evaluation_periods        = "2"
  metric_name               = "BytesIn"
  namespace                 = "AWS/Transfer"
  period                    = "3600"
  statistic                 = "Sum"
  threshold                 = "0"
  alarm_description         = "This metric monitors ftp connection"
  insufficient_data_actions = []
  
  dimensions = {
    ServerId = "<some server id>"
  }

}

由于您知道ServerId 的值,添加它应该不是问题。


[1]https://docs.aws.amazon.com/transfer/latest/userguide/monitoring.html#metrics

[2]https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm#example-of-monitoring-healthy-hosts-on-nlb-using-target-group-and-nlb

【讨论】:

    猜你喜欢
    • 2021-04-09
    • 2014-12-21
    • 1970-01-01
    • 2019-12-26
    • 2019-05-04
    • 2018-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多