【问题标题】:How do I set a separate message for warning vs alert in terraform for Datadog?如何在 Datadog 的 terraform 中为警告和警报设置单独的消息?
【发布时间】:2020-07-08 05:08:21
【问题描述】:

我正在设置一个如下所示的监视器:

resource "datadog_monitor" "queue_size_critical" {
  message = "High Priority"
  name    = "too many messages in queue"
  query   = "max(last_10m):max:aws.sqs.approximate_number_of_messages_visible{aws_account:<account>,queuename:<queuename>} > 10"
  type    = "metric alert"
  tags    = my_tags
  thresholds = {
    ok = 0
    warning = 1
    critical = 10
  }
  renotify_interval = 1440
}

我还有一个看起来像这样的小部件:

widget {
  alert_value_definition {
    alert_id = datadog_monitor.queue_size_critical.id
    title    = datadog_monitor.queue_size_critical.name
  }
}

我想定义两种不同的消息,其中一个将在超过“警告”阈值时发送,另一个将在超过“临界”阈值时发送。

我该怎么做?

这对吗?

resource "datadog_monitor" "queue_size_critical" {
      message = "{{#is_alert}}High Priority{{/is_alert}}
                 {{#is_warning}}Low priority{{/is_warning}}
                 This gets sent every time, in every message."
      name    = "too many messages in queue"
      query   = bla bla bla
      ...etc...
}

【问题讨论】:

    标签: terraform monitor threshold datadog


    【解决方案1】:

    这一切都在message 属性和conditional logic variables 中处理。

    例如,如果您将 message 值定义为...

    {{#is_alert}}
    High Priority @pagerduty
    {{/is_alert}}
    
    {{#is_warning}}
    Medium Priority @slack-mychannel
    {{/is_warning}}
    
    You should reference [this dashboard](mydashboardlink) to see how bad this is and follow [these steps](myrunbook) to resolve the situation.
    

    ...然后...

    1. 当您的监视器超过警报阈值时,它会在消息中包含“高优先级”,并向您的 pagerduty 集成发送通知,
    2. 当它超过警告阈值时,它将包含“中优先级”并向您的闲置频道“mychannel”发送通知,并且
    3. 带有有趣链接的“您应该参考”部分将始终显示。

    【讨论】:

    • 我在文档中看到了条件逻辑变量,但我的问题是我不知道如何在 terraform 中使用它们(我只能在 Datadog Web UI 中找到有关使用它们的文档) .您能否举例说明如何将您的答案整合到我发布的 terraform 代码中?
    • 我编辑了我的信息以显示我认为正确的处理方式。你能确认一下吗?
    • 太好了,非常感谢!我不知道它只是将它全部放在消息字符串中那么简单。
    猜你喜欢
    • 1970-01-01
    • 2021-11-17
    • 2018-10-23
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多