I'm trying to create an alert on CGP/stackdriver using the http/server/response_count metric for app engine. This metric has an response_code field that I can group_by:
fetch gae_app::appengine.googleapis.com/http/server/response_count
| filter metric.response_code>=500 && metric.response_code<600
| every 10m
| group_by [metric.response_code], sum(val())
But say I want to merge all 500+ responses under a 5xx class of response and then aggregate to a single count for the range, is it possible to pre-process so the group_by in the above example yields a single time series eg 5xx? I notice that one of the load balancer metrics has a "response_code_class" of this kind, but this is NOT available for this metric.
After that I'm looking for a ratio of 5xx requests to all requests, would that even be possible with this metric?

There's another way to compute the ratio of error responses to all responses. In this case, because the numerator and denominator for the ratio are derived from the same time series, you can also compute the ratio by grouping. Please check the grouping query format once:
For more details please refer to example grouping.