google-cloud-platformgoogle-cloud-monitoring

Manually triggering alert in Google Cloud Monitoring


I want to be able to programmatically trigger alerts in Google Cloud Monitoring. Basically I have a watchdog that I want to execute certain actions based on multiple criteria. One of those actions is that I want it to trigger a new alert in Google Cloud Monitoring.

Is there a smooth way to do this?

So far my best guess is:

  1. Setup an alert policy on a custom metric (like isTriggeringAlert>0)
  2. Write the actions to a log ("[ALERT]: ....") and use Cloud Monitoring to catch that log

Both works, but was wondering if there is a programatic way to trigger instead? I haven't found anything in the Python SDK for Cloud Monitoring (just how to create monitoring policies)

Regards, Niklas


Solution

  • This feature has been requested, but isn't available yet.
    As a workaround, you can try writing appropriate data into timeSeries using this API.