Grafana 仪表板变量:如何在度量等于某个值时提取标签值

问题描述

我有一个指标来监控名为 nodejs_microservice_health_status 的微服务的健康状态。

我想创建一个变量 Failedmicroservice,它在 service 等于 0 时提取指标的 nodejs_microservice_health_status 标签的值。

PromQL 查询 nodejs_microservice_health_status == bool 0 返回所有等于 0 的项目,但是当我尝试将变量的查询设置为 label_values({nodejs_microservice_health_status == bool 0},service) 时,

enter image description here

我收到以下错误

enter image description here

有人知道怎么做吗?

解决方法

使用以下值,

查询:

query_result(nodejs_microservice_health_status==0)

正则表达式:

/.*service=\"([^\"]+)\".*/