Skip to content

Commit

Permalink
Plumb through more notification_channels. (#113)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Moore <mattmoor@chainguard.dev>
  • Loading branch information
mattmoor authored Feb 2, 2024
1 parent 07f762d commit ae75aea
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions modules/cloudevent-broker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ No requirements.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | n/a | `string` | n/a | yes |
| <a name="input_notification_channels"></a> [notification\_channels](#input\_notification\_channels) | List of notification channels to alert. | `list(string)` | `[]` | no |
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | n/a | `string` | n/a | yes |
| <a name="input_regions"></a> [regions](#input\_regions) | A map from region names to a network and subnetwork. A pub/sub topic and ingress service (publishing to the respective topic) will be created in each region, with the ingress service configured to egress all traffic via the specified subnetwork. | <pre>map(object({<br> network = string<br> subnet = string<br> }))</pre> | n/a | yes |

Expand Down
2 changes: 2 additions & 0 deletions modules/cloudevent-broker/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ module "resources" {
title = "Resources"
filter = ["resource.type=\"cloud_run_revision\"", "resource.labels.service_name=\"${var.name}\""]
cloudrun_name = var.name

notification_channels = var.notification_channels
}

module "width" { source = "../dashboard/sections/width" }
Expand Down
6 changes: 6 additions & 0 deletions modules/cloudevent-broker/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ variable "regions" {
subnet = string
}))
}

variable "notification_channels" {
description = "List of notification channels to alert."
type = list(string)
default = []
}
3 changes: 2 additions & 1 deletion modules/cloudevent-recorder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ No requirements.
| <a name="input_deletion_protection"></a> [deletion\_protection](#input\_deletion\_protection) | Whether to enable deletion protection on data resources. | `bool` | `true` | no |
| <a name="input_location"></a> [location](#input\_location) | The location to create the BigQuery dataset in, and in which to run the data transfer jobs from GCS. | `string` | `"US"` | no |
| <a name="input_name"></a> [name](#input\_name) | n/a | `string` | n/a | yes |
| <a name="input_notification_channels"></a> [notification\_channels](#input\_notification\_channels) | List of notification channels to alert (for service-level issues). | `list(string)` | `[]` | no |
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | n/a | `string` | n/a | yes |
| <a name="input_provisioner"></a> [provisioner](#input\_provisioner) | The identity as which this module will be applied (so it may be granted permission to 'act as' the DTS service account). This should be in the form expected by an IAM subject (e.g. user:sally@example.com) | `string` | n/a | yes |
| <a name="input_regions"></a> [regions](#input\_regions) | A map from region names to a network and subnetwork. A recorder service and cloud storage bucket (into which the service writes events) will be created in each region. | <pre>map(object({<br> network = string<br> subnet = string<br> }))</pre> | n/a | yes |
| <a name="input_retention-period"></a> [retention-period](#input\_retention-period) | The number of days to retain data in BigQuery. | `number` | n/a | yes |
| <a name="input_types"></a> [types](#input\_types) | A map from cloudevent types to the BigQuery schema associated with them, as well as an alert threshold and a list of notification channels | <pre>map(object({<br> schema = string<br> alert_threshold = optional(number, 50000)<br> notification_channels = optional(list(string), [])<br> }))</pre> | n/a | yes |
| <a name="input_types"></a> [types](#input\_types) | A map from cloudevent types to the BigQuery schema associated with them, as well as an alert threshold and a list of notification channels (for subscription-level issues). | <pre>map(object({<br> schema = string<br> alert_threshold = optional(number, 50000)<br> notification_channels = optional(list(string), [])<br> }))</pre> | n/a | yes |

## Outputs

Expand Down
2 changes: 2 additions & 0 deletions modules/cloudevent-recorder/recorder.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ module "recorder-dashboard" {

labels = { for type, schema in var.types : replace(type, ".", "_") => "" }

notification_channels = var.notification_channels

triggers = {
for type, schema in var.types : "type: ${type}" => {
subscription_prefix = "${var.name}-${random_id.trigger-suffix[type].hex}"
Expand Down
8 changes: 7 additions & 1 deletion modules/cloudevent-recorder/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ variable "broker" {
description = "A map from each of the input region names to the name of the Broker topic in that region."
}

variable "notification_channels" {
description = "List of notification channels to alert (for service-level issues)."
type = list(string)
default = []
}

variable "types" {
description = "A map from cloudevent types to the BigQuery schema associated with them, as well as an alert threshold and a list of notification channels"
description = "A map from cloudevent types to the BigQuery schema associated with them, as well as an alert threshold and a list of notification channels (for subscription-level issues)."

type = map(object({
schema = string
Expand Down
1 change: 1 addition & 0 deletions modules/dashboard/cloudevent-receiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ No requirements.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_labels"></a> [labels](#input\_labels) | Additional labels to apply to the dashboard. | `map` | `{}` | no |
| <a name="input_notification_channels"></a> [notification\_channels](#input\_notification\_channels) | List of notification channels to alert. | `list(string)` | `[]` | no |
| <a name="input_service_name"></a> [service\_name](#input\_service\_name) | Name of the service(s) to monitor | `string` | n/a | yes |
| <a name="input_triggers"></a> [triggers](#input\_triggers) | A mapping from a descriptive name to a subscription name prefix, an alert threshold, and list of notification channels. | <pre>map(object({<br> subscription_prefix = string<br> alert_threshold = optional(number, 50000)<br> notification_channels = optional(list(string), [])<br> }))</pre> | n/a | yes |

Expand Down
10 changes: 6 additions & 4 deletions modules/dashboard/cloudevent-receiver/dashboard.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@ module "resources" {
title = "Resources"
filter = ["resource.type=\"cloud_run_revision\"", "resource.labels.service_name=\"${var.service_name}\""]
cloudrun_name = var.service_name

notification_channels = var.notification_channels
}

module "width" { source = "../sections/width" }

module "layout" {
source = "../sections/layout"
sections = concat([
for key in sort(keys(var.triggers)) : module.subscription[key].section
],
sections = concat(
[for key in sort(keys(var.triggers)) : module.subscription[key].section],
[
module.logs.section,
module.http.section,
module.resources.section,
])
],
)
}

resource "google_monitoring_dashboard" "dashboard" {
Expand Down
6 changes: 6 additions & 0 deletions modules/dashboard/cloudevent-receiver/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ variable "triggers" {
notification_channels = optional(list(string), [])
}))
}

variable "notification_channels" {
description = "List of notification channels to alert."
type = list(string)
default = []
}

0 comments on commit ae75aea

Please sign in to comment.