Skip to content

Commit

Permalink
Add support for labeling dashboards. (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmoor authored Dec 21, 2023
1 parent 0280d33 commit e3d0224
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cloudevent-broker/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ module "layout" {
resource "google_monitoring_dashboard" "dashboard" {
dashboard_json = jsonencode({
displayName = "Cloud Events Broker Ingress: ${var.name}"
labels = {
"service" : ""
"eventing" : ""
}
dashboardFilters = [{
filterType = "RESOURCE_LABEL"
stringValue = var.name
Expand Down
1 change: 1 addition & 0 deletions dashboard/cloudevent-receiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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_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. | `map(string)` | n/a | yes |

Expand Down
4 changes: 4 additions & 0 deletions dashboard/cloudevent-receiver/dashboard.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ module "layout" {
resource "google_monitoring_dashboard" "dashboard" {
dashboard_json = jsonencode({
displayName = "Cloud Event Receiver: ${var.service_name}"
labels = merge({
"service" : ""
"eventing" : ""
}, var.labels)
dashboardFilters = [{
filterType = "RESOURCE_LABEL"
stringValue = var.service_name
Expand Down
5 changes: 5 additions & 0 deletions dashboard/cloudevent-receiver/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ variable "service_name" {
type = string
}

variable "labels" {
description = "Additional labels to apply to the dashboard."
default = {}
}

variable "triggers" {
description = "A mapping from a descriptive name to a subscription name prefix."
type = map(string)
Expand Down
1 change: 1 addition & 0 deletions dashboard/job/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ No requirements.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_job_name"></a> [job\_name](#input\_job\_name) | Name of the job(s) to monitor | `string` | n/a | yes |
| <a name="input_labels"></a> [labels](#input\_labels) | Additional labels to apply to the dashboard. | `map` | `{}` | no |

## Outputs

Expand Down
3 changes: 3 additions & 0 deletions dashboard/job/dashboard.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module "layout" {
resource "google_monitoring_dashboard" "dashboard" {
dashboard_json = jsonencode({
displayName = "Cloud Run Job: ${var.job_name}"
labels = merge({
"job" : ""
}, var.labels)
dashboardFilters = [{
filterType = "RESOURCE_LABEL"
stringValue = var.job_name
Expand Down
4 changes: 4 additions & 0 deletions dashboard/job/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ variable "job_name" {
type = string
}

variable "labels" {
description = "Additional labels to apply to the dashboard."
default = {}
}
1 change: 1 addition & 0 deletions dashboard/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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_service_name"></a> [service\_name](#input\_service\_name) | Name of the service(s) to monitor | `string` | n/a | yes |

## Outputs
Expand Down
3 changes: 3 additions & 0 deletions dashboard/service/dashboard.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ module "layout" {
resource "google_monitoring_dashboard" "dashboard" {
dashboard_json = jsonencode({
displayName = "Cloud Run Service: ${var.service_name}"
labels = merge({
"service" : ""
}, var.labels)
dashboardFilters = [{
filterType = "RESOURCE_LABEL"
stringValue = var.service_name
Expand Down
5 changes: 5 additions & 0 deletions dashboard/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ variable "service_name" {
description = "Name of the service(s) to monitor"
type = string
}

variable "labels" {
description = "Additional labels to apply to the dashboard."
default = {}
}

0 comments on commit e3d0224

Please sign in to comment.