Skip to content

GCP Monitoring

udx-github edited this page Sep 9, 2026 · 4 revisions

Creates GCP monitoring alert policies and notification channels for a project.

Use this module when a Rabbit service needs monitoring alerts for Cloud SQL metrics or other GCP resources with Slack or email notifications.

Supported Features

  • Google Cloud Monitoring API enablement.
  • Alert policies with configurable conditions, thresholds, and durations.
  • Multiple alert severity levels.
  • Notification channels for email and Slack.
  • Notification rate limiting and auto-close periods.
  • Notification channel grouping to route alerts to specific channels.
  • Per-series alignment configuration.

Prerequisites

  • GCP credentials with permission to manage monitoring resources.
  • The monitoring.googleapis.com API enabled on the project.
  • A Slack auth token when using Slack notification channels.

Important Notes

  • Alert policies reference notification channels by group membership. Each notification channel has a groups field, and each alert policy lists which groups it notifies.
  • severity can be CRITICAL, WARNING, or ERROR.
  • combiner controls how multiple conditions combine: OR or AND.
  • per_series_aligner and alignment_period control how metric data is aligned before threshold evaluation.

Minimal Example

services:
  - name: "GCP Monitoring"
    module: "gcp-monitoring"
    id: "monitoring"
    deployment_order: 140
    configurations:
      alert_policies:
        db_free_storage_space:
          display_name: "Database Free Storage Space"
          condition_name: "Free storage space threshold"
          condition: "metric.type=\"cloudsql.googleapis.com/database/disk/utilization\" AND resource.type=\"cloudsql_database\""
          comparison: "COMPARISON_GT"
          duration: "60s"
          threshold_value: "90"
          severity: "CRITICAL"
          enabled: true
          groups:
            - "ops"
      notification_channels:
        email_ops:
          name: "ops@example.com"
          type: "email"
          email: "ops@example.com"
          groups: "ops"

Outputs

Output Description
notification_channel_ids The IDs of the created notification channels.
alert_policy_ids The IDs of the created alert policies.

Full Configuration Schema

The fields below are public module inputs under configurations.

configurations:
  google_api_name: "monitoring.googleapis.com"
  alert_policies:
    <policy_key>:
      display_name: ""
      condition_name: ""
      condition: ""
      comparison: "COMPARISON_GT"
      duration: "60s"
      threshold_value: "90"
      severity: "CRITICAL"
      notification_rate_limit_period: "3600s"
      auto_close_period: "24h"
      per_series_aligner: "ALIGN_MIN"
      alignment_period: "60s"
      combiner: "OR"
      enabled: true
      documentation_content: ""
      environment: "development"
      groups: []
  notification_channels:
    <channel_key>:
      name: ""
      type: "email"
      email: ""
      groups: ""

Top-Level Fields

Field Type Required Description
google_api_name string No GCP API to enable. Defaults to monitoring.googleapis.com.
alert_policies map[alert_policy] No Map of alert policy definitions.
notification_channels map[notification_channel] No Map of notification channel definitions.

alert_policies

Field Type Required Description
display_name string Yes Alert policy display name.
condition_name string Yes Condition display name.
condition string Yes Monitoring filter expression.
comparison string Yes Comparison operator, such as COMPARISON_GT.
duration string No Duration the condition must be met. Defaults to 60s.
threshold_value string Yes Threshold value for the condition.
severity string No Alert severity: CRITICAL, WARNING, or ERROR. Defaults to CRITICAL.
notification_rate_limit_period string No Minimum interval between notifications. Defaults to 3600s.
auto_close_period string No Auto-close duration for incidents. Defaults to 24h.
per_series_aligner string No Alignment function. Defaults to ALIGN_MIN.
alignment_period string No Alignment period. Defaults to 60s.
combiner string No Condition combiner: OR or AND. Defaults to OR.
enabled boolean No Enables the alert policy. Defaults to true.
documentation_content string No Documentation attached to the alert.
environment string No Environment label. Defaults to development.
groups array[string] No Notification channel groups to notify.

notification_channels

Field Type Required Description
name string Yes Channel display name.
type string Yes Channel type: email or slack.
email string Conditional Email address. Required when type is email.
channel_name string Conditional Slack channel name. Required when type is slack.
team string Conditional Slack workspace name. Required when type is slack.
auth_token string Conditional Slack auth token. Required when type is slack.
groups string Yes Group identifier for routing alerts.

Removing a channel from notification_channels deletes it on the next apply, even while alert policies still list it: the Monitoring API detaches the channel from those policies as part of the delete, and the policies are then updated to the configured channel list in the same run.

Clone this wiki locally