Skip to content
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

add dashboard modules #14

Merged
merged 15 commits into from
Dec 19, 2023
3 changes: 3 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
- cloudevent-trigger
- cloudevent-recorder
- networking
- dashboard/service
- dashboard/job
- dashboard/topic
mattmoor marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop for now

Suggested change
- dashboard/topic


steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
4 changes: 3 additions & 1 deletion cloudevent-broker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ No requirements.

## Modules

No modules.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_ingress-dashboard"></a> [ingress-dashboard](#module\_ingress-dashboard) | ../dashboard/service | n/a |

## Resources

Expand Down
5 changes: 5 additions & 0 deletions cloudevent-broker/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,8 @@ resource "google_cloud_run_v2_service" "this" {
}
}
}

module "ingress-dashboard" {
source = "../dashboard/service"
service_name = google_cloud_run_v2_service.this.name
}
1 change: 1 addition & 0 deletions cloudevent-recorder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ No requirements.

| Name | Source | Version |
|------|--------|---------|
| <a name="module_recorder-dashboard"></a> [recorder-dashboard](#module\_recorder-dashboard) | ../dashboard/service | n/a |
| <a name="module_triggers"></a> [triggers](#module\_triggers) | ../cloudevent-trigger | n/a |

## Resources
Expand Down
6 changes: 6 additions & 0 deletions cloudevent-recorder/recorder.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ module "triggers" {
name = google_cloud_run_v2_service.recorder-service[each.value.region].name
}
}

module "recorder-dashboard" {
source = "../dashboard/service"
project_id = var.project_id
service_name = google_cloud_run_v2_service.recorder-service.name
}
38 changes: 38 additions & 0 deletions dashboard/job/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- 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_cpu_utilization"></a> [cpu\_utilization](#module\_cpu\_utilization) | ../widgets/xy | n/a |
| <a name="module_logs"></a> [logs](#module\_logs) | ../widgets/logs | n/a |
| <a name="module_memory_utilization"></a> [memory\_utilization](#module\_memory\_utilization) | ../widgets/xy | n/a |
| <a name="module_received_bytes"></a> [received\_bytes](#module\_received\_bytes) | ../widgets/xy | n/a |
| <a name="module_sent_bytes"></a> [sent\_bytes](#module\_sent\_bytes) | ../widgets/xy | n/a |
| <a name="module_startup_latency"></a> [startup\_latency](#module\_startup\_latency) | ../widgets/xy | 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_job_name"></a> [job\_name](#input\_job\_name) | Name of the job(s) to monitor | `string` | n/a | yes |

## Outputs

No outputs.
<!-- END_TF_DOCS -->
70 changes: 70 additions & 0 deletions dashboard/job/dashboard.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
locals { common_filter = ["resource.type=\"cloud_run_job\""] }

module "logs" {
source = "../widgets/logs"
title = "Service Logs"
filter = local.common_filter
}

module "cpu_utilization" {
source = "../widgets/xy"
title = "CPU utilization"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/cpu/utilizations\""])
primary_align = "ALIGN_DELTA"
primary_reduce = "REDUCE_MEAN"
}

module "memory_utilization" {
source = "../widgets/xy"
title = "Memory utilization"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/memory/utilizations\""])
primary_align = "ALIGN_DELTA"
primary_reduce = "REDUCE_MEAN"
}

module "startup_latency" {
source = "../widgets/xy"
title = "Startup latency"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/startup_latencies\""])
primary_align = "ALIGN_DELTA"
primary_reduce = "REDUCE_MEAN"
}

module "sent_bytes" {
source = "../widgets/xy"
title = "Sent bytes"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/network/sent_bytes_count\""])
primary_align = "ALIGN_MEAN"
primary_reduce = "REDUCE_NONE"
}

module "received_bytes" {
source = "../widgets/xy"
title = "Received bytes"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/network/received_bytes_count\""])
primary_align = "ALIGN_MEAN"
primary_reduce = "REDUCE_NONE"
}

resource "google_monitoring_dashboard" "dashboard" {
dashboard_json = jsonencode({
displayName = "Cloud Run Job: ${var.job_name}"
dashboardFilters = [{
filterType = "RESOURCE_LABEL"
stringValue = var.job_name
labelKey = "job_name"
}]
// https://cloud.google.com/monitoring/api/ref_v3/rest/v1/projects.dashboards#GridLayout
gridLayout = {
columns = 3
widgets = [
module.logs.tile,
module.cpu_utilization.tile,
module.memory_utilization.tile,
module.startup_latency.tile,
module.sent_bytes.tile,
module.received_bytes.tile,
]
}
})
}
5 changes: 5 additions & 0 deletions dashboard/job/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "job_name" {
description = "Name of the job(s) to monitor"
type = string
}

41 changes: 41 additions & 0 deletions dashboard/service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!-- 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_cpu_utilization"></a> [cpu\_utilization](#module\_cpu\_utilization) | ../widgets/xy | n/a |
| <a name="module_incoming_latency"></a> [incoming\_latency](#module\_incoming\_latency) | ../widgets/latency | n/a |
| <a name="module_instance_count"></a> [instance\_count](#module\_instance\_count) | ../widgets/xy | n/a |
| <a name="module_logs"></a> [logs](#module\_logs) | ../widgets/logs | n/a |
| <a name="module_memory_utilization"></a> [memory\_utilization](#module\_memory\_utilization) | ../widgets/xy | n/a |
| <a name="module_received_bytes"></a> [received\_bytes](#module\_received\_bytes) | ../widgets/xy | n/a |
| <a name="module_request_count"></a> [request\_count](#module\_request\_count) | ../widgets/xy | n/a |
| <a name="module_sent_bytes"></a> [sent\_bytes](#module\_sent\_bytes) | ../widgets/xy | n/a |
| <a name="module_startup_latency"></a> [startup\_latency](#module\_startup\_latency) | ../widgets/xy | 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 |

## Outputs

No outputs.
<!-- END_TF_DOCS -->
100 changes: 100 additions & 0 deletions dashboard/service/dashboard.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
locals { common_filter = ["resource.type=\"cloud_run_revision\""] }

module "logs" {
source = "../widgets/logs"
title = "Service Logs"
filter = local.common_filter
}

module "request_count" {
source = "../widgets/xy"
title = "Request count"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/request_count\""])
group_by_fields = ["metric.label.\"response_code_class\""]
primary_align = "ALIGN_RATE"
primary_reduce = "REDUCE_NONE"
secondary_align = "ALIGN_NONE"
secondary_reduce = "REDUCE_SUM"
}

module "incoming_latency" {
source = "../widgets/latency"
title = "Incoming request latency"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/request_latencies\""])
}

module "instance_count" {
source = "../widgets/xy"
title = "Instance count + revisions"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/instance_count\""])
group_by_fields = ["resource.label.\"revision_name\""]
primary_align = "ALIGN_MEAN"
primary_reduce = "REDUCE_SUM"
plot_type = "STACKED_AREA"
}

module "cpu_utilization" {
source = "../widgets/xy"
title = "CPU utilization"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/cpu/utilizations\""])
primary_align = "ALIGN_DELTA"
primary_reduce = "REDUCE_MEAN"
}

module "memory_utilization" {
source = "../widgets/xy"
title = "Memory utilization"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/memory/utilizations\""])
primary_align = "ALIGN_DELTA"
primary_reduce = "REDUCE_MEAN"
}

module "startup_latency" {
source = "../widgets/xy"
title = "Startup latency"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/startup_latencies\""])
primary_align = "ALIGN_DELTA"
primary_reduce = "REDUCE_MEAN"
}

module "sent_bytes" {
source = "../widgets/xy"
title = "Sent bytes"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/network/sent_bytes_count\""])
primary_align = "ALIGN_MEAN"
primary_reduce = "REDUCE_NONE"
}

module "received_bytes" {
source = "../widgets/xy"
title = "Received bytes"
filter = concat(local.common_filter, ["metric.type=\"run.googleapis.com/container/network/received_bytes_count\""])
primary_align = "ALIGN_MEAN"
primary_reduce = "REDUCE_NONE"
}

resource "google_monitoring_dashboard" "dashboard" {
dashboard_json = jsonencode({
displayName = "Cloud Run Service: ${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#GridLayout
gridLayout = {
columns = 3
widgets = [
module.logs.tile,
module.request_count.tile,
module.incoming_latency.tile,
module.instance_count.tile,
module.cpu_utilization.tile,
module.memory_utilization.tile,
module.startup_latency.tile,
module.sent_bytes.tile,
module.received_bytes.tile,
]
}
})
}
4 changes: 4 additions & 0 deletions dashboard/service/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "service_name" {
description = "Name of the service(s) to monitor"
type = string
}
37 changes: 37 additions & 0 deletions dashboard/subscription/README.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop for now

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!-- 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_oldest-unacked"></a> [oldest-unacked](#module\_oldest-unacked) | ../widgets/xy | n/a |
| <a name="module_push-latency"></a> [push-latency](#module\_push-latency) | ../widgets/latency | n/a |
| <a name="module_received-events"></a> [received-events](#module\_received-events) | ../widgets/xy | n/a |
| <a name="module_undelivered"></a> [undelivered](#module\_undelivered) | ../widgets/xy | 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_alert_policies"></a> [alert\_policies](#input\_alert\_policies) | n/a | <pre>map(object({<br> id = string<br> }))</pre> | `{}` | no |
| <a name="input_subscription_prefix"></a> [subscription\_prefix](#input\_subscription\_prefix) | n/a | `string` | n/a | yes |

## Outputs

No outputs.
<!-- END_TF_DOCS -->
Loading
Loading