You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GCP监控创建PubSub告警策略时Delta指标比值报错

问题:PubSub告警策略创建报错(分子为Delta指标但分母不是)

我尝试针对PubSub订阅的失败消息比值创建告警策略,使用pubsub.googleapis.com/subscription/dead_letter_message_count作为分子,pubsub.googleapis.com/subscription/pull_ack_request_count作为分母。已确保对齐周期匹配,且通过Cross Series Reducer移除了分母的额外标签,拟创建的告警策略如下:

monitoring/alertPolicy:AlertPolicy:
        combiner   : "AND"
        conditions : [
            [0]: {
                conditionThreshold: {
                    aggregations           : [
                        [0]: {
                            alignmentPeriod   : "600s"
                            crossSeriesReducer: "REDUCE_SUM"
                            perSeriesAligner  : "ALIGN_SUM"
                        }
                    ]
                    comparison             : "COMPARISON_GT"
                    denominatorAggregations: [
                        [0]: {
                            alignmentPeriod   : "600s"
                            crossSeriesReducer: "REDUCE_SUM"
                            perSeriesAligner  : "ALIGN_SUM"
                        }
                    ]
                    denominatorFilter      : "resource.type = \"pubsub_subscription\" AND resource.labels.subscription_id = \"subscription\" AND metric.type = \"pubsub.googleapis.com/subscription/pull_ack_request_count\""
                    duration               : "1800s"
                    filter                 : "resource.type = \"pubsub_subscription\" AND resource.labels.subscription_id = \"subscription\" AND metric.type = \"pubsub.googleapis.com/subscription/dead_letter_message_count\""
                    thresholdValue         : 0.5
                }
            }
        ]

但创建时出现以下报错:

Error creating AlertPolicy: googleapi: Error 400: The numerator is a delta metric but the denominator is not a delta metric.

这让人困惑,因为两个指标都是Delta类型。我通过API Explorer获取了时间序列数据:

分子指标数据(dead_letter_message_count)

{
  "timeSeries": [
    {
      "metric": {
        "type": "pubsub.googleapis.com/subscription/dead_letter_message_count"
      },
      "resource": {
        "type": "pubsub_subscription",
        "labels": {
          "project_id": "redacted"
        }
      },
      "metricKind": "DELTA",
      "valueType": "INT64",
      "points": [
        {
          "interval": {
            "startTime": "2023-03-13T10:10:00Z",
            "endTime": "2023-03-13T10:20:00Z"
          },
          "value": {
            "int64Value": "0"
          }
        },
        ....,
        {
          "interval": {
            "startTime": "2023-03-13T09:10:00Z",
            "endTime": "2023-03-13T09:20:00Z"
          },
          "value": {
            "int64Value": "93"
          }
        },
        {
          "interval": {
            "startTime": "2023-03-13T09:00:00Z",
            "endTime": "2023-03-13T09:10:00Z"
          },
          "value": {
            "int64Value": "9"
          }
        },
        {
          "interval": {
            "startTime": "2023-03-13T08:50:00Z",
            "endTime": "2023-03-13T09:00:00Z"
          },
          "value": {
            "int64Value": "34"
          }
        }
      ]
    }
  ],
  "unit": "1"
}

分母指标数据(pull_ack_request_count)

{
  "timeSeries": [
    {
      "metric": {
        "type": "pubsub.googleapis.com/subscription/pull_ack_request_count"
      },
      "resource": {
        "type": "pubsub_subscription",
        "labels": {
          "project_id": "redacted"
        }
      },
      "metricKind": "DELTA",
      "valueType": "INT64",
      "points": [
        {
          "interval": {
            "startTime": "2023-03-13T09:50:00Z",
            "endTime": "2023-03-13T10:00:00Z"
          },
          "value": {
            "int64Value": "6"
          }
        },
        ....,
        {
          "interval": {
            "startTime": "2023-03-13T08:20:00Z",
            "endTime": "2023-03-13T08:30:00Z"
          },
          "value": {
            "int64Value": "104"
          }
        },
        {
          "interval": {
            "startTime": "2023-03-13T08:10:00Z",
            "endTime": "2023-03-13T08:20:00Z"
          },
          "value": {
            "int64Value": "93"
          }
        },
        {
          "interval": {
            "startTime": "2023-03-13T08:00:00Z",
            "endTime": "2023-03-13T08:10:00Z"
          },
          "value": {
            "int64Value": "111"
          }
        }
      ]
    }
  ],
  "unit": "1"
}

内容的提问来源于stack exchange,提问作者reith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 04:07:07