From 9344781f75612e4a651454221953e52c3d5a3843 Mon Sep 17 00:00:00 2001 From: Andrew Pollock Date: Tue, 11 Feb 2025 05:54:50 +0000 Subject: [PATCH] feat(monitoring): add notifications to k8s CronJob monitoring in staging This adds the standard notification channel to the alerting policies in staging. --- deployment/terraform/environments/oss-vdb-test/main.tf | 1 + .../terraform/modules/k8s_cron_alert/k8s_cron_alert.tf | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/deployment/terraform/environments/oss-vdb-test/main.tf b/deployment/terraform/environments/oss-vdb-test/main.tf index d3d57d82468..ae6dec6e9e6 100644 --- a/deployment/terraform/environments/oss-vdb-test/main.tf +++ b/deployment/terraform/environments/oss-vdb-test/main.tf @@ -44,6 +44,7 @@ module "k8s_cron_alert" { project_id = module.osv_test.project_id cronjob_name = each.value.metadata.name cronjob_expected_latency_minutes = lookup(each.value.metadata.labels, "cronLastSuccessfulTimeMins", null) + notification_channel = "projects/oss-vdb-test/notificationChannels/14282948683609643269" } import { diff --git a/deployment/terraform/modules/k8s_cron_alert/k8s_cron_alert.tf b/deployment/terraform/modules/k8s_cron_alert/k8s_cron_alert.tf index 2e670045e95..a12b339428b 100644 --- a/deployment/terraform/modules/k8s_cron_alert/k8s_cron_alert.tf +++ b/deployment/terraform/modules/k8s_cron_alert/k8s_cron_alert.tf @@ -13,6 +13,12 @@ variable "cronjob_expected_latency_minutes" { description = "Expected amount of time since last successful run of the job expressed in minutes." } +variable "notification_channel" { + type = string + description = "(Optional) The notification channel to send alerts to." + default = null +} + resource "google_monitoring_alert_policy" "cron_alert_policy" { project = var.project_id display_name = "Cronjob: ${var.cronjob_name} has not run recently." @@ -27,4 +33,6 @@ resource "google_monitoring_alert_policy" "cron_alert_policy" { rule_group = "cronjob ${var.cronjob_name}" } } + + notification_channels = var.notification_channel != null ? toset([var.notification_channel]) : toset([]) }