diff --git a/dashboard/sections/grpc/grpc.tf b/dashboard/sections/grpc/grpc.tf
new file mode 100644
index 00000000..fb0126bb
--- /dev/null
+++ b/dashboard/sections/grpc/grpc.tf
@@ -0,0 +1,105 @@
+variable "title" { type = string }
+variable "filter" { type = list(string) }
+variable "collapsed" { default = false }
+variable "grpc_service_name" { type = string }
+
+module "width" { source = "../width" }
+
+module "request_count" {
+ source = "../../widgets/xy"
+ title = "Request count"
+ filter = concat(var.filter, [
+ "metric.type=\"prometheus.googleapis.com/grpc_server_handled_total/counter\"",
+ "metric.label.grpc_service=monitoring.regex.full_match(\"${var.grpc_service_name}.*\")",
+ ])
+ group_by_fields = [
+ "metric.label.\"grpc_service\"",
+ "metric.label.\"grpc_method\"",
+ "metric.label.\"grpc_code\""
+ ]
+ 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(var.filter, [
+ "metric.type=\"prometheus.googleapis.com/grpc_server_handling_seconds/histogram\"",
+ "metric.label.\"grpc_service\"=monitoring.regex.full_match(\"${var.grpc_service_name}.*\")",
+ ])
+ group_by_fields = [
+ "metric.label.\"grpc_service\"",
+ "metric.label.\"grpc_method\"",
+ ]
+}
+
+module "outbound_request_count" {
+ source = "../../widgets/xy"
+ title = "Request count"
+ filter = concat(var.filter, [
+ "metric.type=\"prometheus.googleapis.com/grpc_server_handled_total/counter\"",
+ "metric.label.grpc_service=monitoring.regex.full_match(\"${var.grpc_service_name}.*\")",
+ ])
+ group_by_fields = [
+ "metric.label.\"grpc_service\"",
+ "metric.label.\"grpc_method\"",
+ "metric.label.\"grpc_code\""
+ ]
+ primary_align = "ALIGN_RATE"
+ primary_reduce = "REDUCE_NONE"
+ secondary_align = "ALIGN_NONE"
+ secondary_reduce = "REDUCE_SUM"
+}
+
+module "outbound_latency" {
+ source = "../../widgets/latency"
+ title = "Incoming request latency"
+ filter = concat(var.filter, [
+ "metric.type=\"prometheus.googleapis.com/grpc_server_handling_seconds/histogram\"",
+ "metric.label.\"grpc_service\"=monitoring.regex.full_match(\"chainguard.datastore.*\")",
+ ])
+ group_by_fields = [
+ "metric.label.\"grpc_service\"",
+ "metric.label.\"grpc_method\"",
+ ]
+}
+
+locals {
+ columns = 2
+ 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.request_count.widget,
+ }, {
+ yPos = 0
+ xPos = local.col[1],
+ height = local.unit,
+ width = local.unit,
+ widget = module.incoming_latency.widget,
+ },
+ ]
+}
+
+module "collapsible" {
+ source = "../collapsible"
+
+ title = var.title
+ tiles = local.tiles
+ collapsed = var.collapsed
+}
+
+output "section" {
+ value = module.collapsible.section
+}
diff --git a/dashboard/service/README.md b/dashboard/service/README.md
index e3b159b6..37ae27b4 100644
--- a/dashboard/service/README.md
+++ b/dashboard/service/README.md
@@ -53,6 +53,7 @@ No requirements.
| Name | Source | Version |
|------|--------|---------|
| [alerts](#module\_alerts) | ../sections/alerts | n/a |
+| [grpc](#module\_grpc) | ../sections/grpc | n/a |
| [http](#module\_http) | ../sections/http | n/a |
| [layout](#module\_layout) | ../sections/layout | n/a |
| [logs](#module\_logs) | ../sections/logs | n/a |
@@ -70,6 +71,7 @@ No requirements.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [alerts](#input\_alerts) | Alerting policies to add to the dashboard. | `list(string)` | `[]` | no |
+| [grpc\_service\_name](#input\_grpc\_service\_name) | Name of the GRPC service(s) to monitor | `string` | `""` | no |
| [labels](#input\_labels) | Additional labels to apply to the dashboard. | `map` | `{}` | no |
| [service\_name](#input\_service\_name) | Name of the service(s) to monitor | `string` | n/a | yes |
diff --git a/dashboard/service/dashboard.tf b/dashboard/service/dashboard.tf
index 1e017338..ffa7ef99 100644
--- a/dashboard/service/dashboard.tf
+++ b/dashboard/service/dashboard.tf
@@ -11,6 +11,13 @@ module "http" {
service_name = var.service_name
}
+module "grpc" {
+ source = "../sections/grpc"
+ title = "GRPC"
+ filter = []
+ grpc_service_name = var.grpc_service_name
+}
+
module "resources" {
source = "../sections/resources"
title = "Resources"
@@ -34,6 +41,7 @@ module "layout" {
[
module.logs.section,
module.http.section,
+ module.grpc.section,
module.resources.section,
]
)
diff --git a/dashboard/service/variables.tf b/dashboard/service/variables.tf
index ba152ec4..8fe62fe2 100644
--- a/dashboard/service/variables.tf
+++ b/dashboard/service/variables.tf
@@ -14,3 +14,11 @@ variable "alerts" {
default = []
}
+# Currently our metrics does not have service_name label: we
+# are working around by specifying the grpc_service name label
+# instead while we fix the metric labeling.
+variable "grpc_service_name" {
+ description = "Name of the GRPC service(s) to monitor"
+ type = string
+ default = ""
+}