Skip to content

Alert policy in terraform for workflow failures #269

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,41 @@ resource "google_monitoring_alert_policy" "limit_alert" {
}
}

resource "google_monitoring_alert_policy" "simulation_workflow_failure_alert" {
project = var.project_id
display_name = "Simulation Workflow Failures"
combiner = "OR"

conditions {
display_name = "Simulation Workflow Failed in Last 5 Minutes"
condition_prometheus_query_language {
query = <<-EOT
increase(workflows_googleapis_com:finished_execution_count{monitored_resource="workflows.googleapis.com/Workflow",status="FAILED"}[5m]) > 1
EOT
duration = "300s"
evaluation_interval = "60s"
labels = {
severity = "critical"
}
}
}

notification_channels = local.notification_channels

documentation {
content = <<-EOT
🚨 *Simulation Workflow Failure Alert*

One or more executions of the simulation workflow failed within the last 5 minutes.

*Steps:*
- Check Cloud Workflows logs: [View Details](https://console.cloud.google.com/workflows/workflow/${var.region}/simulation-workflow/metrics?project=${var.project_id})
- Confirm input data
- Review recent deploys: [Latest commit](${var.commit_url})
EOT
mime_type = "text/markdown"
}

enabled = true
}