I'm building a metric for the success rate of my API gateway and I'm trying to get more that 1-2 decimal places. I want to make sure that less than 99.9999% are successful. (Ultimately to set an alarm), but I would like to show this detail in the dashboard.
Is there some kind of value formatting syntax available. I have been digging around in the docs and haven't found anything.
{
"metrics": [
[ { "expression": "100*(1-(m1+m2/m3))", "label": "Success Rate", "id": "e1" } ],
[ "AWS/ApiGateway", "4XXError", "ApiName", "my_webhook_api", "Stage", "prod", { "id": "m1", "visible": false } ],
[ ".", "5XXError", ".", ".", ".", ".", { "id": "m2", "visible": false } ],
[ ".", "Count", ".", ".", ".", ".", { "id": "m3", "visible": false } ]
],
"view": "singleValue",
"region": "us-west-2",
"stat": "Sum",
"period": 2592000,
"setPeriodToTimeRange": true
}
Basically, I want the picture below to say 99.8XXXXX (6 decimal places)
You should be able to accomplish this with Metric Math. Multiply by 1000000 FLOOR
the result to get an integer then divide by 1000000 to get a floating point number again.
FLOOR(1000000*(100*(1-(m1+m2/m3))))/1000000)
In the new-style CloudWatch UI (activated by the "Try out the new interface" link in the top-right corner) there's an Options tab where there's an option to "Show as many digits as can fit, before rounding", see the screenshot:
As an alternative, open the Source tab and add the following option to the top-level object (in the provided example this can be after the line with setPeriodToTimeRange
): "singleValueFullPrecision": true
.
This doesn't let you control the number of decimal digits, but achieves the goal of displaying numbers with high precision.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With