Skip to content

Commit

Permalink
allow extra filter for dlq alert policy (#461)
Browse files Browse the repository at this point in the history
Signed-off-by: Kenny Leung <kleung@chainguard.dev>
  • Loading branch information
k4leung4 authored Jul 24, 2024
1 parent f27d8de commit 9c76998
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/alerting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_dlq_filter"></a> [dlq\_filter](#input\_dlq\_filter) | additional filter to apply to dlq alert policy | `string` | `""` | no |
| <a name="input_failed_req_filter"></a> [failed\_req\_filter](#input\_failed\_req\_filter) | additional filter to apply to failed request alert policy | `string` | `""` | no |
| <a name="input_failure_rate_duration"></a> [failure\_rate\_duration](#input\_failure\_rate\_duration) | duration for condition to be active before alerting | `number` | `120` | no |
| <a name="input_failure_rate_exclude_services"></a> [failure\_rate\_exclude\_services](#input\_failure\_rate\_exclude\_services) | List of service names to exclude from the 5xx failure rate alert | `list(string)` | `[]` | no |
Expand Down
7 changes: 6 additions & 1 deletion modules/alerting/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,12 @@ resource "google_monitoring_alert_policy" "pubsub_dead_letter_queue_messages" {

comparison = "COMPARISON_GT"
duration = "0s"
filter = "metric.type=\"pubsub.googleapis.com/topic/send_request_count\" resource.type=\"pubsub_topic\" metadata.system_labels.\"name\"=~\".*-dlq-.*\""
filter = <<EOT
metric.type="pubsub.googleapis.com/topic/send_request_count"
resource.type="pubsub_topic"
metadata.system_labels."name"=~".*-dlq-.*"
${var.dlq_filter}
EOT

trigger {
count = "1"
Expand Down
6 changes: 6 additions & 0 deletions modules/alerting/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ variable "failure_rate_exclude_services" {
type = list(string)
default = []
}

variable "dlq_filter" {
description = "additional filter to apply to dlq alert policy"
type = string
default = ""
}

0 comments on commit 9c76998

Please sign in to comment.