1
votes

I want to export a status in a label, something like this:

my_status{group="xx",partition="1",status="ERROR"} 1
my_status{group="xx",partition="1",status="OK"} 1
my_status{group="xx",partition="1",status="STALL"} 1

I've read Brian's https://www.robustperception.io/exposing-the-software-version-to-prometheus What I'm trying to do is pretty similar.

And query the status in Grafana, given group and partition. But I can't do queries like shown in the example

my_status{group="xx",partition="1"} 
* on (partition, group) group_left(status) 
my_status{group="xx",partition="1"}

This gives me an error because they are now two different time series, which leads to

Error executing query: many-to-many matching not allowed: matching labels must be unique on one side

I don't want to export the enum by mapping them into value. (e.g. OK=1, ERROR=2), because I'd have to keep updating them. Any pointers? Thanks.

1

1 Answers

0
votes

The issue here is that you are reporting three statuses. If exactly one had a value of 1 you could do

  up
* on (partition, group) group_left(status)
  (my_status{group="xx",partition="1"} == 1)