tse
tse

Reputation: 6069

How to request Prometheus percentage instead of count?

I use Graphana do display data from Prometheus. I have request to display quantity of "failed" events (I mean success="false"):

count(test{deviceserial=~"$device",branch=~"$branch",
   class=~"$class",build_id=~"$build_id",success="false"}) by (deviceserial)

How to request/display percentage of failed instead of absolute value?

Upvotes: 2

Views: 7091

Answers (1)

Alin Sînpălean
Alin Sînpălean

Reputation: 10074

count by (deviceserial) (test{deviceserial=~"$device",branch=~"$branch",
        class=~"$class",build_id=~"$build_id",success="false"})
  /
count by (deviceserial) (test{deviceserial=~"$device",branch=~"$branch",
        class=~"$class",build_id=~"$build_id"})```

Note the missing success="false" from the second selector. I'm assuming here you have a metric test with the listed labels and particularly success="true" when the test succeeds and success="false"when it fails.

Upvotes: 2

Related Questions