please help and find below the alert policies using filter metrics. content of .tfvars
//.tfvars content
alert_template = {
"dataproc-job-fail" = {
enabled = true
duration = "900s"
display_name = "dataproc job fail"
threshold_value = 0
alignment_period = "60s"
per_series_aligner = "ALIGN_RATE"
cross_series_reducer = "REDUCE_COUNT"
group_by_fields = ["metric.label.error_type","resource.label.cluster_name","metric.label.job_type"]
filter = "metric.type="dataproc.googleapis.com/cluster/job/failed_count" AND resource.type="cloud_dataproc_cluster""
severity = "CRITICAL"
content = "testing alert policy"
alert_strategy_auto_close = "604800s"
comparison = "COMPARISON_GT"
},
{ "dataproc-operation-fail" = {
enabled = true
duration = "900s"
display_name = "dataproc operation fail"
threshold_value = 0
alignment_period = "60s"
per_series_aligner = "ALIGN_RATE"
cross_series_reducer = "REDUCE_COUNT"
group_by_fields = ["metric.label.error_type","resource.label.cluster_name","metric.label.operation_type"]
filter = "metric.type="dataproc.googleapis.com/cluster/operation/failed_count" AND resource.type="cloud_dataproc_cluster""
severity = "CRITICAL"
content = "testing alert policy"
alert_strategy_auto_close = "604800s"
comparison = "COMPARISON_GT"
},
{ "composer-health" = {
enabled = true
duration = "900s"
display_name = "Composer Health Alert"
threshold_value = 0.95
alignment_period = "60s"
per_series_aligner = "ALIGN_FRACTION_TRUE"
cross_series_reducer = "REDUCE_MEAN"
group_by_fields = ["metric.label.error_type","resource.label.cluster_name","metric.label.operation_type"]
filter = "metric.type="composer.googleapis.com/environment/healthy" AND resource.type="cloud_composer_environment""
severity = "CRITICAL"
content = "testing alert policy"
alert_strategy_auto_close = "604800s"
comparison = "COMPARISON_LT"
}
}
//main.tf file content
resource "google_monitoring_alert_policy" "alerts_template_policy" {
for_each = var.alert_template
enabled = each.value.enabled
project = var.project_id
display_name = each.value.display_name
severity = each.value.severity
combiner = "OR"
conditions {
display_name = each.value.display_name
condition_threshold {
filter = each.value.filter
duration = each.value.duration
comparison = each.value.comparison
threshold_value = each.value.threshold_value
aggregations {
alignment_period = each.value.alignment_period
per_series_aligner = each.value.per_series_aligner
group_by_fields = each.value.group_by_fields
cross_series_reducer = each.value.cross_series_reducer
}
}
alert_strategy {
auto_close = each.value.alert_strategy_auto_close
}
documentation {
content = each.value.content
}
notification_channels = [
for channel in google_monitoring_notifications_channel.alert_notifications : channel.name ]
}
on terraform plan, thee plan is successfull and apply is also successfull, but not getting alerts for this policy in email, also configured some other service with template and getting the alerts but not for abovee ones. please help.
New contributor
Ayub is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.