Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(monitoring): add notifications to k8s CronJob monitoring in staging #3124

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deployment/terraform/environments/oss-vdb-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions deployment/terraform/modules/k8s_cron_alert/k8s_cron_alert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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([])
}
Loading