简体   繁体   中英

How to get google cloud platform alert status via REST apis

I have created an alert policy in google cloud platform. I am getting the emails notifications based on the alert policy. Now I want to configure an external custom monitoring system for this alert. I want to know the REST APIs that this monitoring system can call at after every 10-20 sec and get the status of this alert.

Please help

If you want to use only Cloud Monitoring , and Alerting Policy you won't achieve this.

It is not possible to configure alert policies to notify (repeatedly) while the policy's conditions are met. Alert policies that are created through Google Cloud Console send a notification only when the condition is met. You can also receive a notification when the condition stops being met.

Additional information can be found in Notifications per incident documentation.

In Cloud Monitoring API v3 - Alerting policies , you can find information that only the creation of the incident is sent.

An alerting policy is a configuration resource that describes the criteria for generating incidents and how to notify you when those incidents are created.

In general, if you want to use Notification Channels to send notifications outside you can use Webhooks or PubSub .

Note

Webhooks only support public endpoints. If you need notifications sent to an endpoint that isn't public, then create a Pub/Sub notification channel and configure a subscription to the Pub/Sub topic. For more information, see Webhook notifications fail when configured for a private endpoint .

As you didn't provide more information it's hard to say if you are not using some built-in features in 3rd party software to integrate with GCP Cloud Monitoring. One of the example is Grafana :

Grafana ships with built-in support for Google Cloud Monitoring. Add it as a data source to build dashboards for your Google Cloud Monitoring metrics.

GCP also might use Prometheus features. Maybe this might give you something similar to what you want.

Prometheus is a monitoring tool often used with Kube.netes. If you configure Cloud Operations for GKE and include Prometheus support, then the metrics that are generated by services using the Prometheus exposition format can be exported from the cluster and made visible as external metrics in Cloud Monitoring.

There are some workarounds, however they won't fulfill what you want.

  • It is possible to create multiple conditions that identify the same issue. Every time a condition is met, a notification will be received.
  • It is possible to get users notified when a condition is NOT met, however this might cause spam messages.

The last thing I want to mention is that there is already a Feature Request to add multiple notifications until the condition is gone. More details in FR: Repeat Notifications until condition is gone .

Additional Documentation:

Conclusion

  • Alert policies that are created through Google Cloud Console send a notification only when the condition is met. You can also enable notification to get solved notification.
  • There is Feature Request to add repeatedly notifications - here
  • To send notifications to other apps/resources you can use Webhooks or PubSub .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM