Calculate error rate from two rows based on dimension

  • What are you trying to achieve?
    Hi there, I am trying to make a status history graph showing the error / success situation of the system. Ideally with an error rate (error / (error + success)).

  • How are you trying to achieve it?
    I did a search to AWS cloudwatch, which contains two different MetricNames (Error and Success) and used regex to show different colors of errors and success.

  • What happened?


    I would like to combine the two metrics of each dimension (e.g. B - failed and B - success) into one row based on math expressions. I tried expression, but I couldn’t specify which rows will be combined. With binary operation under “Add field from calculation” it is only possible to do basic ±*/ , but I want something like error / (success + error).

Any suggestions?

you can do two binary operation steps,

success + error = total

then

error / total

then error * 100 if you want percent

1 Like

Thanks for the reply. I thought of that as well. Surely it’s a good workaround. But ideally I would like to have something that make the calculation using the rows with the same label instead of manually choosing the two rows in a binary calculation, because the incoming data can be versatile.

1 Like

IMHO you can use CloudWatch math in this case:

You can use CloudWatch math also in the Grafana.

1 Like

Thanks for the suggestion. As mentioned, I tried the calculation in expression already, but I couldn’t specify which rows will be combined. So if I use $a + $b, then all rows returned from $a will be added to all rows returned from $b.

CloudWatch math != Grafana expression.

Could you elaborate a bit more, please? I thought the math in expression is the way to do something like cloudwatch math in Grafana environment. Or do you mean doing cloudwatch math in AWS in advance?

Cloudwatch math in AWS => you can use cloudwatch math also in Grafana (but that’s not a Grafana expression). Search on the forum and you will find example how. E.g.