[英]Creating a cloud-function error alerting policy in GCP with terraform
我正在尝试为 GCP 中的云功能的错误日志制定警报策略。 我在使用以下日志进行地形改造时遇到问题。
AND severity>=ERROR": The lefthand side of each expression must be prefixed with one of {group, metadata, metric, project, resource}.
我正在使用的 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
}
任何帮助深表感谢:)
发现错误,我在条件中使用了错误的块
这是正确的 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.