I want to create an alert when the success rate for my cloud function falls below certain threshold. I created an alert policy that checks the ratio of successful requests (status=ok) to all requests. The MQL query looks like this:
fetch cloud_function
| metric 'cloudfunctions.googleapis.com/function/execution_count'
| filter resource.function_name == 'my-function'
| { t_0:
filter metric.status == 'ok'
| align delta()
| group_by [resource.function_name],
[value_execution_count_aggregate: aggregate(value.execution_count)]
; t_1:
ident
| align delta()
| group_by [resource.function_name],
[value_execution_count_aggregate: aggregate(value.execution_count)] }
| ratio
| window 60m
| condition ratio < 0.99 '1'
Hi @antonff,
Welcome to Google Cloud Community!
As of the moment, here are the documentations that contains all the operations (so far) that may be helpful for your MQL queries:
You could also check Cloud Monitoring overview as you may also find this helpful.
I also suggest filing a feature request so that our engineers could take a look at this. We don't have a specific ETA on this but you can keep track of its progress once the ticket has been created.
Hope this helps.