【问题标题】:GCP Cloud monitoring using terraform for allowing "Response Code Classes" in uptime alert creationGCP 云监控使用 terraform 以允许在正常运行时间警报创建中使用“响应代码类”
【发布时间】:2022-11-10 15:04:22
【问题描述】:

所以我有我的 terraform 文件,我在其中创建了正常运行时间检查,我正在检查 SSL 证书而不是正常运行时间,配置它只是为了检查证书过期。 现在假设默认情况下

我允许了可接受的 HTTP 响应代码 200,但如果我也想允许 404 代码,那么如果网站提供 404 响应但仍然通过测试,我该如何在 terraform 代码中允许它..?

所以例如

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
  }

  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"
    }
  }
}

如果我单击测试选项,则通过

但我也需要允许 404,以便如果返回也是 404,测试也将通过。 任何人都可以帮助我使用正确的代码,在可接受的 HTTP 响应代码->响应代码类下包含 404 允许 404 和 200。

【问题讨论】:

    标签: terraform-provider-gcp google-cloud-monitoring uptime-monitoring


    【解决方案1】:

    您可以指定确切的响应代码:

    http_check {
        path = "/some-path"
        port = "443"
        use_ssl = true
        validate_ssl = true
        accepted_response_status_codes {
          status_class = "STATUS_CLASS_2XX"
        }
        accepted_response_status_codes {
                status_value = 404
        }
        accepted_response_status_codes {
                status_value = 302
        }
      }
    

    【讨论】:

      猜你喜欢
      • 2021-09-14
      • 2021-11-21
      • 1970-01-01
      • 2021-11-08
      • 1970-01-01
      • 2021-05-29
      • 1970-01-01
      • 2022-01-12
      • 2021-07-11
      相关资源
      最近更新 更多