Ken Tsoi
Ken Tsoi

Reputation: 1303

Grafana dashboard Variables: how to extract a label value when the metric equal to a value

I have a metric to monitor the health status of microservices called nodejs_microservice_health_status.

I want to create a variable failedmicroservice which extracts the value of the service label of the metrics when nodejs_microservice_health_status equals to 0.

The PromQL query nodejs_microservice_health_status == bool 0 returns all the items equals to 0, but when I tried to set the Query of the variable to label_values({nodejs_microservice_health_status == bool 0}, service), enter image description here

I got the following error:

enter image description here

Do anyone knows how to do this?

Upvotes: 1

Views: 6480

Answers (1)

Use the following values,

Query:

query_result(nodejs_microservice_health_status==0)

Regex:

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

Upvotes: 4

Related Questions