简体   繁体   English

使用 terraform 在 GCP 中创建云功能错误警报策略

[英]Creating a cloud-function error alerting policy in GCP with terraform

I am trying to make an alerting policy for error logs for cloud functions in GCP.我正在尝试为 GCP 中的云功能的错误日志制定警报策略。 I am having an issue from terraforming with the following logs.我在使用以下日志进行地形改造时遇到问题。

AND severity>=ERROR": The lefthand side of each expression must be prefixed with one of {group, metadata, metric, project, resource}.

The tf code block I am using is this, the issue is using the severity>=ERROR section我正在使用的 tf 代码块是这个,问题是使用 severity>=ERROR 部分

resource "google_monitoring_alert_policy" "cloud_function_errors" {
      project               = var.project
      enabled               = var.alerts_enabled
      display_name          = "${var.cf_name}-errors"
      combiner              = "OR"
      conditions {
        display_name = "${var.cf_name}-errors"
        condition_threshold {
          filter     = "resource.type=\"cloud_function\" resource.labels.function_name=\"${var.cf_name}\"  resource.labels.project_id=${var.project} AND severity>=ERROR"
          duration   = "0s"
          comparison = "COMPARISON_GT"
        }
      }
      notification_channels = var.alerts_notification_channels
    }

Any help is much appreciated:)任何帮助深表感谢:)

Found the error, I was using the wrong block inside conditions发现错误,我在条件中使用了错误的块

here is the correct tf block这是正确的 tf 块

resource "google_monitoring_alert_policy" "cloud_function_errors" {
  project      = var.project
  enabled      = var.alerts_enabled
  display_name = "${var.cf_name}-errors"
  combiner     = "OR"

  conditions {
    display_name = "${var.cf_name}-errors"
    condition_matched_log {
      filter = "resource.type=\"cloud_function\" resource.labels.function_name=\"${var.cf_name}\"  resource.labels.project_id=${var.project} AND severity>=ERROR"
    }
  }

  alert_strategy {
    auto_close = "604800s"
    notification_rate_limit {
      period = "3600s"
    }
  }
  notification_channels = var.alerts_notification_channels
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 失败的 GKE CronJob 的 GCP 警报策略 - GCP Alerting Policy for failed GKE CronJob 云监控创建告警策略时阈值字段是什么意思? - What is the meaning of the Threshold value field when creating an Alerting policy in Cloud Monitoring? Firestore 云功能更新所有文档中的字段与参数 - Firestore cloud-function to update a field in all doc in coll with parameter 谷歌云平台——创建警报策略——如何在警报文档降价中指定消息变量? - google cloud platform -- creating alert policy -- how to specify message variable in alerting documentation markdown? 是否可以在Terraform中更新GCP Cloud Function的源代码? - Is it possible to update the source code of a GCP Cloud Function in Terraform? 使用 Eventarc 创建一个目标为云函数的 terraform - Creating a terraform with Eventarc with its destination to cloud function Terraform Google 提供商,创建基于日志的警报策略 - Terraform Google provider, create log-based alerting policy GCP Cloud Build 和 Terraform 集成 - GCP Cloud Build and Terraform integration terraform GCP 云 function 无需通过 terraform 在 CI 中部署或在本地运行时打破过去的部署? - terraform GCP cloud function without having to deploy via terraform in CI or breaking past deployments when running locally? Google Cloud Functions 2 Terraform 部署失败(错误等待创建function,容器健康检查失败) - Google Cloud Functions 2 Terraform fails to deploy (error waiting for creating function, container healthcheck failed)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM