【问题标题】:Stackdriver alert policy not triggeringStackdriver 提醒政策未触发
【发布时间】:2019-08-26 09:52:00
【问题描述】:

我有一个基于日志的自定义指标,基于我的应用程序发出的日志,如下所示:

resource.type="k8s_container" resource.labels.cluster_name="my-cluster" resource.labels.namespace_name="preprod" resource.labels.container_name="my-app" jsonPayload.logType="MyEventType"

我想根据它设置一个自定义警报策略,并让它在 10 分钟内没有日志时触发警报。

我做了如下的事情:

{
  "combiner": "OR",
  "conditions": [
    {
      "conditionAbsent": {
        "aggregations": [
          {
            "alignmentPeriod": "60s",
            "perSeriesAligner": "ALIGN_SUM"
          }
        ],
        "duration": "600s",
        "filter": "metric.type=\"logging.googleapis.com/user/my-metric-preprod\" resource.type=\"k8s_container\"",
        "trigger": {
          "percent": 100
        }
      },
      "displayName": "No log events for 10 mins"
    }
  ],
  "displayName": "My custom policy - preprod",
  "enabled": true,
  "notificationChannels": // doesn't matter
}

虽然一切看起来都很好,但当我停止发出事件时,什么都没有执行。

我错过了什么吗?

【问题讨论】:

    标签: gcloud stackdriver google-cloud-stackdriver


    【解决方案1】:

    我已经在您的 JSON 中使用相同的值复制了它;

       {
      "combiner": "OR",
      "conditions": [
        {
          "conditionAbsent": {
            "aggregations": [
              {
                "alignmentPeriod": "60s",
                "perSeriesAligner": "ALIGN_SUM"
              }
            ],
            "duration": "180s",
            "filter": "metric.type=\"logging.googleapis.com/user/test-alerting\" resource.type=\"k8s_container\"",
            "trigger": {
              "percent": 100
            }
          },
          "displayName": "logging/user/test-alerting"
        }
      ],
      "displayName": "testing",
      "enabled": true,
      "notificationChannels": [
        "NOTIFICATION/CHANNEL/123"
      ]
    }
    

    不知道为什么您的提醒不起作用,您是否验证了通知渠道?

    【讨论】:

    • 我以为你是在一个alignmentPeriod上求和,你确定它是所有时间数据的总和吗?
    • Align time series via aggregation. The resulting data point in the alignment period is the sum of all data points in the period. This alignment is valid for gauge and delta metrics with numeric and distribution values. The value type of the output is the same as the value type of the input. - 这里的alignmentPeriod是60s,所以我假设它需要60s的滑动窗口。
    • 我已经用相同的配置复制了这个并且通知正在工作。
    • 当您使用 Metrics Explorer 或 Monitoring API 读取指标数据时,您可以使用聚合来汇总时间序列数据。聚合通常从一个**对齐步骤开始,其中每个时间序列的数据都放置在相同的时间边界上**。接下来,通过组合来自多个时间序列的数据点,使用平均值、求和、最小值、最大值等操作来创建一个新的时间序列。见:cloud.google.com/monitoring/custom-metrics/… & cloud.google.com/monitoring/api/ref_v3/rest/v3/…
    猜你喜欢
    • 1970-01-01
    • 2019-09-19
    • 2020-11-02
    • 2020-01-08
    • 1970-01-01
    • 2020-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多