如何使用 Google 监控查询语言从不同的资源类型中获取指标?
How to use Google Monitoring Query Language to fetch metrics from different resource types?
我正在尝试在 Google 云上创建一个警报,以使用 Google 监控查询语言通知有关 Pub/Sub 无法转发到死信主题的消息.
关于Google documentation,据说:
To verify that Pub/Sub is forwarding undeliverable messages, you can compare the subscription/dead_letter_message_count metric with the topic/send_message_operation_count metric from the topic that Pub/Sub forwards these messages to.
但是,当尝试使用查询编辑器创建警报条件时,出现以下错误:
Metric 'pubsub.googleapis.com/topic/send_message_operation_count' is not compatible with resource 'pubsub_subscription'. Consider using the following resource(s): 'pubsub_topic'.
我想知道是否可以使用 Google 监控查询语言获取主题和订阅指标,如果可以,如何获取?
您可以在查询编辑器中获取主题和订阅指标,但您需要为每个指标指定正确的资源类型。您可以通过以下方式获取 pubsub.googleapis.com/topic/send_message_operation_count
:
fetch pubsub_topic
| metric 'pubsub.googleapis.com/topic/send_message_operation_count'
和pubsub.googleapis.com/subscription/dead_letter_message_count
与
fetch pubsub_subscription
| metric 'pubsub.googleapis.com/subscription/dead_letter_message_count'
为了在单个警报中同时使用这两个指标,您需要使用连接。
下面是一个示例,说明如何配置警报以验证发布率不会低于死信率超过 1 QPS/min:
{
fetch pubsub_subscription
| metric 'pubsub.googleapis.com/subscription/dead_letter_message_count'
| filter resource.subscription_id = "my-sub"
| group_by [], sum(val())
| align rate(1m)
| every 1m
;
fetch pubsub_topic
| metric 'pubsub.googleapis.com/topic/send_message_operation_count'
| filter resource.topic_id = "my-dead-letter-topic"
| group_by [], sum(val())
| align rate(1m)
| every 1m
}
| join
| sub
| condition val() > 1 # 1/min
我正在尝试在 Google 云上创建一个警报,以使用 Google 监控查询语言通知有关 Pub/Sub 无法转发到死信主题的消息.
关于Google documentation,据说:
To verify that Pub/Sub is forwarding undeliverable messages, you can compare the subscription/dead_letter_message_count metric with the topic/send_message_operation_count metric from the topic that Pub/Sub forwards these messages to.
但是,当尝试使用查询编辑器创建警报条件时,出现以下错误:
Metric 'pubsub.googleapis.com/topic/send_message_operation_count' is not compatible with resource 'pubsub_subscription'. Consider using the following resource(s): 'pubsub_topic'.
我想知道是否可以使用 Google 监控查询语言获取主题和订阅指标,如果可以,如何获取?
您可以在查询编辑器中获取主题和订阅指标,但您需要为每个指标指定正确的资源类型。您可以通过以下方式获取 pubsub.googleapis.com/topic/send_message_operation_count
:
fetch pubsub_topic
| metric 'pubsub.googleapis.com/topic/send_message_operation_count'
和pubsub.googleapis.com/subscription/dead_letter_message_count
与
fetch pubsub_subscription
| metric 'pubsub.googleapis.com/subscription/dead_letter_message_count'
为了在单个警报中同时使用这两个指标,您需要使用连接。
下面是一个示例,说明如何配置警报以验证发布率不会低于死信率超过 1 QPS/min:
{
fetch pubsub_subscription
| metric 'pubsub.googleapis.com/subscription/dead_letter_message_count'
| filter resource.subscription_id = "my-sub"
| group_by [], sum(val())
| align rate(1m)
| every 1m
;
fetch pubsub_topic
| metric 'pubsub.googleapis.com/topic/send_message_operation_count'
| filter resource.topic_id = "my-dead-letter-topic"
| group_by [], sum(val())
| align rate(1m)
| every 1m
}
| join
| sub
| condition val() > 1 # 1/min