Google Cloud (Stackdriver) Monitoring Alert Policy

This page shows how to write Terraform for Cloud (Stackdriver) Monitoring Alert Policy and write them securely.

code-icon

Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.

get-started-button

Terraform Example (google_monitoring_alert_policy)

A description of the conditions under which some aspect of your system is considered to be "unhealthy" and the ways to notify people or services about this state. To get more information about AlertPolicy, see:

Parameters

  • combiner required - string
    • How to combine the results of multiple conditions to determine if an incident should be opened. Possible values: ["AND", "OR", "AND_WITH_MATCHING_RESOURCE"]

  • creation_record requiredcomputed - list / object
    • A read-only record of the creation of the alerting policy. If provided in a call to create or update, this field will be ignored.

  • display_name required - string
    • A short name or phrase used to identify the policy in dashboards, notifications, and incidents. To avoid confusion, don't use the same display name for multiple policies in the same project. The name is limited to 512 Unicode characters.

  • enabled optional - bool
    • Whether or not the policy is enabled. The default is true.

  • id optionalcomputed - string
  • name requiredcomputed - string
    • The unique resource name for this policy. Its syntax is: projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]

  • notification_channels optional - list / string
    • Identifies the notification channels to which notifications should be sent when incidents are opened or closed or when new violations occur on an already opened incident. Each element of this array corresponds to the name field in each of the NotificationChannel objects that are returned from the notificationChannels.list method. The syntax of the entries in this field is 'projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]'

  • project optionalcomputed - string
  • user_labels optional - map / string
    • This field is intended to be used for organizing and identifying the AlertPolicy objects.The field can contain up to 64 entries. Each key and value is limited to 63 Unicode characters or 128 bytes, whichever is smaller. Labels and values can contain only lowercase letters, numerals, underscores, and dashes. Keys must begin with a letter.

Example Usage (from GitHub)

github-iconshudhanshh/Freelance-TF-Project
resource "google_monitoring_alert_policy" "alert_policy_project_ownership" {
 notification_channels = [
   google_monitoring_notification_channel.email0.name,
   google_monitoring_notification_channel.email1.name ]
  display_name = "project-ownership"
  combiner     = "OR"
github-iconaliz-ai/terraform-aliz-modules
resource "google_monitoring_alert_policy" "all_bgp_sessions_down" {

  count = var.all_bgp_sessions_down ? 1 : 0

  combiner = "OR"

Frequently asked questions

What is Google Cloud (Stackdriver) Monitoring Alert Policy?

Google Cloud (Stackdriver) Monitoring Alert Policy is a resource for Cloud (Stackdriver) Monitoring of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Cloud (Stackdriver) Monitoring Alert Policy?

For Terraform, the shudhanshh/Freelance-TF-Project and aliz-ai/terraform-aliz-modules source code examples are useful. See the Terraform Example section for further details.