Is it possible to use MQL to include time of day in the alert condition?
Basic example in their documentation includes:
fetch gce_instance :: compute.googleapis.com/instance/cpu/usage_time
| rate (5m)
| condition lt(val(), 0.5's{CPU}/min')
I essentially want to do this:
fetch gce_instance :: compute.googleapis.com/instance/cpu/usage_time
| rate (5m)
| condition lt(val(), 0.5's{CPU}/min') and ( gt(end.time, '06:00:00') and lt(end.time, '18:00:00') )
Obviously that isn't valid, but I'm struggling to put the syntax together for time related functions from their documentation - does anyone know if this is possible?
I also want this so I can silence alerts during scheduled nightly upgrades. I could not find a way to do it with MQL, but here are some workarounds that might help:
I am trying the API approach. The enable/disable calls can be made from my upgrade job, so I don't think I need the scheduler. Here are the steps I used to work this out:
gcloud alpha monitoring policies list
gcloud alpha monitoring policies update projects/<project-name>/alertPolicies/<policy-id> --no-enabled
# Do my upgrade...
gcloud alpha monitoring policies update projects/<project-name>/alertPolicies/<policy-id> --enabled