Cloud Monitoring sends alerts to external tools using notification channels. You can customize the information, or alert payload, sent in these alerts. By using features like Markdown, you can add important details such as specific metric values, which resource is affected, and a link to the relevant policy. This extra context helps the person receiving the alert understand and fix the problem faster.
When an alert fails to deliver to an external service like a webhook, you need to investigate. Common problems include network timeouts, the external service being down, or incorrect configuration settings. To find the root cause, you examine Cloud Logging audit logs for your notification channels. These logs show each delivery attempt, including error codes and messages, which tells you if the issue is with the network path, the target endpoint, or something else.
To ensure alerts are delivered reliably, follow several best practices. Regularly check that your webhook endpoints are correctly configured. Set appropriate timeout values so Cloud Monitoring doesn't give up too quickly on a slow-responding service. Monitor delivery success rates using Cloud Monitoring's own metrics, and consider setting up backup notification channels to avoid a single point of failure if one integration stops working.
For platforms with built-in support, like PagerDuty, you create a direct link called a notification channel. You get a unique integration key from PagerDuty and add it to Cloud Monitoring. When an alerting policy triggers, it uses this channel to automatically create an incident in PagerDuty, sending a payload with all the necessary details about the problem.
A key step in this integration is matching severity levels. By default, PagerDuty might treat all Google Cloud alerts as critical, which is not always correct and can overwhelm teams. To fix this, you configure rules within PagerDuty to look at the incident.severity field sent from Cloud Monitoring. This allows different alert severities to trigger different escalation policies, ensuring a major outage gets immediate attention while a minor warning goes to a backlog.
For tools without a native integration, like Microsoft Teams, you use webhooks as a flexible connector. Cloud Monitoring sends the alert data to a public URL you provide. Sometimes, the external tool cannot understand the raw payload, so you might need a middleman service, like a Cloud Run function, to receive the webhook, translate the data, and then forward it to the final destination in the correct format.
For highly secure or complex environments, a more advanced pattern uses Pub/Sub. Instead of sending alerts directly, Cloud Monitoring publishes them to a message topic. External monitoring platforms like Splunk or Datadog then subscribe to that topic to pull the messages. This approach separates the systems, provides reliable delivery, and allows for deep customization of how the alert data is processed and enriched before the external tool uses it.
A custom webhook notification channel is how you connect Cloud Monitoring to any external service that accepts HTTP calls, like PagerDuty, Rootly, or a custom dashboard. You configure it by providing the public URL of your external service. When an alert fires, Cloud Monitoring sends a structured JSON payload to that URL, which can then automatically create a ticket or trigger an on-call response.
Security is crucial because the webhook endpoint is exposed to the internet. To protect it, you must add authentication to the webhook request. This is typically done by including a secret token in the HTTP headers of the request. You should store this token securely in Google Cloud Secret Manager instead of in plain configuration files. You can also implement payload verification to ensure the incoming alert is genuinely from your Cloud Monitoring system and hasn't been altered.
You set up these channels through the Cloud Monitoring console or its API. After creating the webhook channel and defining its secure headers, you select it within your alerting policies. The connection works in one direction: when the policy conditions are met, Cloud Monitoring creates an incident and immediately dispatches the notification to your external endpoint. The payload contains all the context needed for your team to act, linking the cloud-native alert directly into your company's broader incident management workflow.
Professional Cloud DevOps Engineer
Gauge your current knowledge
Gauge your current knowledge