google_monitoring_uptime_check_config

This message configures which resources and services to monitor for availability.

To get more information about UptimeCheckConfig, see:

Example Usage - Uptime Check Config Http

resource "google_monitoring_uptime_check_config" "http" {
  display_name = "http-uptime-check"
  timeout      = "60s"
  user_labels  = {
    example-key = "example-value"
  }

  http_check {
    path = "some-path"
    port = "8010"
    request_method = "POST"
    content_type = "USER_PROVIDED"
    custom_content_type = "application/json"
    body = "Zm9vJTI1M0RiYXI="
    ping_config {
      pings_count = 1
    }
  }

  monitored_resource {
    type = "uptime_url"
    labels = {
      project_id = "my-project-name"
      host       = "192.168.1.1"
    }
  }

  content_matchers {
    content = "\"example\""
    matcher = "MATCHES_JSON_PATH"
    json_path_matcher {
      json_path = "$.path"
      json_matcher = "EXACT_MATCH"
    }
  }

  checker_type = "STATIC_IP_CHECKERS"
}
## Example Usage - Uptime Check Config Status Code
resource "google_monitoring_uptime_check_config" "status_code" {
  display_name = "http-uptime-check"
  timeout      = "60s"

  http_check {
    path = "some-path"
    port = "8010"
    request_method = "POST"
    content_type = "URL_ENCODED"
    body = "Zm9vJTI1M0RiYXI="

    accepted_response_status_codes {
      status_class = "STATUS_CLASS_2XX"
    }
    accepted_response_status_codes {
            status_value = 301
    }
    accepted_response_status_codes {
            status_value = 302
    }
  }

  monitored_resource {
    type = "uptime_url"
    labels = {
      project_id = "my-project-name"
      host       = "192.168.1.1"
    }
  }

  content_matchers {
    content = "\"example\""
    matcher = "MATCHES_JSON_PATH"
    json_path_matcher {
      json_path = "$.path"
      json_matcher = "EXACT_MATCH"
    }
  }

  checker_type = "STATIC_IP_CHECKERS"
}
## Example Usage - Uptime Check Config Https
resource "google_monitoring_uptime_check_config" "https" {
  display_name = "https-uptime-check"
  timeout = "60s"

  http_check {
    path = "/some-path"
    port = "443"
    use_ssl = true
    validate_ssl = true
    service_agent_authentication {
      type = "OIDC_TOKEN"
    }
  }

  monitored_resource {
    type = "uptime_url"
    labels = {
      project_id = "my-project-name"
      host = "192.168.1.1"
    }
  }

  content_matchers {
    content = "example"
    matcher = "MATCHES_JSON_PATH"
    json_path_matcher {
      json_path = "$.path"
      json_matcher = "REGEX_MATCH"
    }
  }
}
Open in Cloud Shell

Example Usage - Uptime Check Tcp

resource "google_monitoring_uptime_check_config" "tcp_group" {
  display_name = "tcp-uptime-check"
  timeout      = "60s"

  tcp_check {
    port = 888
    ping_config {
      pings_count = 2
    }
  }

  resource_group {
    resource_type = "INSTANCE"
    group_id      = google_monitoring_group.check.name
  }
}

resource "google_monitoring_group" "check" {
  display_name = "uptime-check-group"
  filter       = "resource.metadata.name=has_substring(\"foo\")"
}

Example Usage - Uptime Check Config Synthetic Monitor

resource "google_storage_bucket" "bucket" {
  name     = "my-project-name-gcf-source"  # Every bucket name must be globally unique
  location = "US"
  uniform_bucket_level_access = true
}

resource "google_storage_bucket_object" "object" {
  name   = "function-source.zip"
  bucket = google_storage_bucket.bucket.name
  source = "synthetic-fn-source.zip"  # Add path to the zipped function source code
}

resource "google_cloudfunctions2_function" "function" {
  name = "synthetic_function"
  location = "us-central1"

  build_config {
    runtime = "nodejs16"
    entry_point = "SyntheticFunction"  # Set the entry point 
    source {
      storage_source {
        bucket = google_storage_bucket.bucket.name
        object = google_storage_bucket_object.object.name
      }
    }
  }

  service_config {
    max_instance_count  = 1
    available_memory    = "256M"
    timeout_seconds     = 60
  }
}

resource "google_monitoring_uptime_check_config" "synthetic_monitor" {
  display_name = "synthetic_monitor"
  timeout = "60s"

  synthetic_monitor {
    cloud_function_v2 {
      name = google_cloudfunctions2_function.function.id
    }
  }
}

Argument Reference

The following arguments are supported:


The content_matchers block supports:

The json_path_matcher block supports:

The http_check block supports:

The auth_info block supports:

The service_agent_authentication block supports:

The accepted_response_status_codes block supports:

The ping_config block supports:

The tcp_check block supports:

The ping_config block supports:

The resource_group block supports:

The monitored_resource block supports:

The synthetic_monitor block supports:

The cloud_function_v2 block supports:

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

Timeouts

This resource provides the following Timeouts configuration options:

Import

UptimeCheckConfig can be imported using any of these accepted formats:

In Terraform v1.5.0 and later, use an import block to import UptimeCheckConfig using one of the formats above. For example:

import {
  id = "{{name}}"
  to = google_monitoring_uptime_check_config.default
}

When using the terraform import command, UptimeCheckConfig can be imported using one of the formats above. For example:

$ terraform import google_monitoring_uptime_check_config.default {{name}}

User Project Overrides

This resource supports User Project Overrides.