-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This creates sections for "topics" and "subscriptions" that filter on their respective prefixes. The topic section shows both topic metrics and subscription metrics for topics matching the prefix. The subscription section shows the subscription metrics for subscriptions matching the prefix. Building on this, the broker ingress now has a customized dashboard that takes advantage of the topic metrics to put them front-and-center. Also building on this, the event recorder now includes a section with subscription metrics for each even type. Signed-off-by: Matt Moore <[email protected]>
- Loading branch information
Showing
11 changed files
with
467 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# `dashboard/cloudevent-receiver` | ||
|
||
This module provisions a Google Cloud Monitoring dashboard for a regionalized Cloud Run service that receives Cloud Events from one or more `cloudevent-trigger`. | ||
|
||
It assumes the service has the same name in all regions. | ||
|
||
```hcl | ||
// Create a network with several regional subnets | ||
module "networking" { | ||
source = "chainguard-dev/glue/cloudrun//networking" | ||
name = "my-networking" | ||
project_id = var.project_id | ||
regions = [...] | ||
} | ||
// Run a regionalized cloud run service "receiver" to handle events. | ||
resource "google_cloud_run_v2_service" "receiver" { | ||
for_each = module.networking.regional-networks | ||
name = "receiver" | ||
//... | ||
template { | ||
//... | ||
containers { | ||
image = "..." | ||
} | ||
} | ||
} | ||
module "cloudevent-trigger" { | ||
for_each = module.networking.regional-networks | ||
source = "chainguard-dev/glue/cloudrun//cloudevent-trigger" | ||
name = "my-trigger" | ||
project_id = var.project_id | ||
broker = module.cloudevent-broker.broker[each.key] | ||
filter = { "type" : "dev.chainguard.foo" } | ||
depends_on = [google_cloud_run_v2_service.sockeye] | ||
private-service = { | ||
region = each.key | ||
name = google_cloud_run_v2_service.receiver[each.key].name | ||
} | ||
} | ||
// Set up a dashboard for a regionalized event handler named "receiver". | ||
module "receiver-dashboard" { | ||
source = "chainguard-dev/glue/cloudrun//dashboard/cloudevent-receiver" | ||
service_name = "receiver" | ||
triggers = { | ||
"type dev.chainguard.foo": "my-trigger" | ||
} | ||
} | ||
``` | ||
|
||
The dashboard it creates includes widgets for service logs, request count, latency (p50,p95,p99), instance count grouped by revision, CPU and memory utilization, startup latency, and sent/received bytes. | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_google"></a> [google](#provider\_google) | n/a | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_http"></a> [http](#module\_http) | ../sections/http | n/a | | ||
| <a name="module_layout"></a> [layout](#module\_layout) | ../sections/layout | n/a | | ||
| <a name="module_logs"></a> [logs](#module\_logs) | ../sections/logs | n/a | | ||
| <a name="module_resources"></a> [resources](#module\_resources) | ../sections/resources | n/a | | ||
| <a name="module_subscription"></a> [subscription](#module\_subscription) | ../sections/subscription | n/a | | ||
| <a name="module_width"></a> [width](#module\_width) | ../sections/width | n/a | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [google_monitoring_dashboard.dashboard](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_dashboard) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <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 | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module "subscription" { | ||
for_each = var.triggers | ||
|
||
source = "../sections/subscription" | ||
title = "Events ${each.key}" | ||
|
||
subscription_prefix = each.value | ||
} | ||
|
||
module "logs" { | ||
source = "../sections/logs" | ||
title = "Service Logs" | ||
filter = ["resource.type=\"cloud_run_revision\""] | ||
} | ||
|
||
module "http" { | ||
source = "../sections/http" | ||
title = "HTTP" | ||
filter = ["resource.type=\"cloud_run_revision\""] | ||
} | ||
|
||
module "resources" { | ||
source = "../sections/resources" | ||
title = "Resources" | ||
filter = ["resource.type=\"cloud_run_revision\""] | ||
} | ||
|
||
module "width" { source = "../sections/width" } | ||
|
||
module "layout" { | ||
source = "../sections/layout" | ||
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" { | ||
dashboard_json = jsonencode({ | ||
displayName = "Cloud Event Receiver: ${var.service_name}" | ||
dashboardFilters = [{ | ||
filterType = "RESOURCE_LABEL" | ||
stringValue = var.service_name | ||
labelKey = "service_name" | ||
}] | ||
|
||
// https://cloud.google.com/monitoring/api/ref_v3/rest/v1/projects.dashboards#mosaiclayout | ||
mosaicLayout = { | ||
columns = module.width.size | ||
tiles = module.layout.tiles, | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "service_name" { | ||
description = "Name of the service(s) to monitor" | ||
type = string | ||
} | ||
|
||
variable "triggers" { | ||
description = "A mapping from a descriptive name to a subscription name prefix." | ||
type = map(string) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
variable "title" { type = string } | ||
variable "subscription_prefix" { type = string } | ||
variable "collapsed" { default = false } | ||
|
||
module "width" { source = "../width" } | ||
|
||
module "received-events" { | ||
source = "../../widgets/xy" | ||
title = "Events Pushed" | ||
filter = [ | ||
"resource.type=\"pubsub_subscription\"", | ||
"metric.type=\"pubsub.googleapis.com/subscription/push_request_count\"", | ||
"resource.label.\"subscription_id\"=monitoring.regex.full_match(\"${var.subscription_prefix}-.*\")", | ||
] | ||
group_by_fields = [ | ||
"resource.label.\"subscription_id\"", | ||
"metric.label.\"response_class\"" | ||
] | ||
primary_align = "ALIGN_MEAN" | ||
primary_reduce = "REDUCE_NONE" | ||
} | ||
|
||
module "push-latency" { | ||
source = "../../widgets/latency" | ||
title = "Push latency" | ||
filter = [ | ||
"resource.type=\"pubsub_subscription\"", | ||
"metric.type=\"pubsub.googleapis.com/subscription/push_request_latencies\"", | ||
"resource.label.\"subscription_id\"=monitoring.regex.full_match(\"${var.subscription_prefix}-.*\")", | ||
] | ||
group_by_fields = ["resource.label.\"subscription_id\""] | ||
} | ||
|
||
module "oldest-unacked" { | ||
source = "../../widgets/xy" | ||
title = "Oldest unacked message age" | ||
filter = [ | ||
"resource.type=\"pubsub_subscription\"", | ||
"metric.type=\"pubsub.googleapis.com/subscription/oldest_unacked_message_age\"", | ||
"resource.label.\"subscription_id\"=monitoring.regex.full_match(\"${var.subscription_prefix}-.*\")", | ||
] | ||
group_by_fields = ["resource.label.\"subscription_id\""] | ||
primary_align = "ALIGN_MAX" | ||
primary_reduce = "REDUCE_NONE" | ||
} | ||
|
||
locals { | ||
columns = 3 | ||
unit = module.width.size / local.columns | ||
|
||
// https://www.terraform.io/language/functions/range | ||
// N columns, unit width each ([0, unit, 2 * unit, ...]) | ||
col = range(0, local.columns * local.unit, local.unit) | ||
|
||
tiles = [{ | ||
yPos = 0, | ||
xPos = local.col[0], | ||
height = local.unit, | ||
width = local.unit, | ||
widget = module.received-events.widget, | ||
}, | ||
{ | ||
yPos = 0, | ||
xPos = local.col[1], | ||
height = local.unit, | ||
width = local.unit, | ||
widget = module.push-latency.widget, | ||
}, | ||
{ | ||
yPos = 0, | ||
xPos = local.col[2], | ||
height = local.unit, | ||
width = local.unit, | ||
widget = module.oldest-unacked.widget, | ||
}] | ||
} | ||
|
||
module "collapsible" { | ||
source = "../collapsible" | ||
|
||
title = var.title | ||
tiles = local.tiles | ||
collapsed = var.collapsed | ||
} | ||
|
||
output "section" { | ||
value = module.collapsible.section | ||
} |
Oops, something went wrong.