我正在尝试通过terraform设置监视器,这是我的"helloworld“代码(它可以工作,但不符合我的接受标准):
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.5.0"
}
}
}
provider "google" {
credentials = "some_credentials"
project = "some_project"
region = "some_region"
zone = "some_zone"
}
resource "google_monitoring_notification_channel" "basic" {
display_name = "Test name"
type = "email"
labels = {
email_address = "some@email.com"
}
}
resource "google_monitoring_alert_policy" "cloud_composer_job_fail_monitor" {
combiner = "OR"
display_name = "Fails testing on cloud composer tasks"
notification_channels = [google_monitoring_notification_channel.basic.id]
conditions {
display_name = "Failures count"
condition_threshold {
filter = "resource.type=\"cloud_composer_workflow\" AND metric.type=\"composer.googleapis.com/workflow/task/run_count\" AND resource.label.\"project_id\"=\"some_project\" AND metric.label.\"state\"=\"failed\" AND resource.label.\"location\"=\"some_region\""
duration = "60s"
comparison = "COMPARISON_GT"
threshold_value = 0
aggregations {
alignment_period = "3600s"
per_series_aligner = "ALIGN_COUNT"
}
}
}
documentation {
content = "Please checkout current incident"
}
}
Problem:默认情况下,在触发或解决警报策略(谷歌文档)时会发送通知。
我的问题:我希望在Composer作业失败时(例如)每30分钟发出一次警报通知,直到我或其他人无法解决事件(或者我需要理解为什么在作业停止失败时事件不会自动解决)
有人能帮忙解决这个问题吗?
谢谢你的帮助!
发布于 2021-03-23 14:09:56
问题是要对这些领域进行修改:
因此,这些更改将使您能够获得有关状态失败的composer任务的警报通知,并更快地将触发器更改为满足条件:
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "3.5.0"
}
}
}
provider "google" {
credentials = "some_credentials"
project = "some_project"
region = "some_region"
zone = "some_zone"
}
resource "google_monitoring_notification_channel" "basic" {
display_name = "Test name"
type = "email"
labels = {
email_address = "some@email.com"
}
}
resource "google_monitoring_alert_policy" "cloud_composer_job_fail_monitor" {
combiner = "OR"
display_name = "Fails testing on cloud composer tasks"
notification_channels = [google_monitoring_notification_channel.basic.id]
conditions {
display_name = "Failures count"
condition_threshold {
filter = "resource.type=\"cloud_composer_workflow\" AND metric.type=\"composer.googleapis.com/workflow/task/run_count\" AND resource.label.\"project_id\"=\"some_project\" AND metric.label.\"state\"=\"failed\" AND resource.label.\"location\"=\"some_region\""
duration = "0s"
comparison = "COMPARISON_GT"
threshold_value = 0
aggregations {
alignment_period = "60s"
per_series_aligner = "ALIGN_DELTA"
}
}
}
documentation {
content = "Please checkout current incident"
}
}
在这种设置下,没有关于连续通知的信息(例如,每30分钟一次)。
只有当您的条件被满足时,才会通知您。
https://stackoverflow.com/questions/66699009
复制