From bb4faf394d54f93dcaaedff2f6cff001cfbd8523 Mon Sep 17 00:00:00 2001 From: Nghia Tran Date: Sun, 24 Dec 2023 07:01:48 -0800 Subject: [PATCH] Add gRPC outbounds, remove grpc_service_name (#44) This makes use of what we added in #42 Signed-off-by: Nghia Tran --- dashboard/sections/grpc/grpc.tf | 49 +++++++++++++++++++++++++++++++-- dashboard/service/README.md | 1 - dashboard/service/dashboard.tf | 2 +- dashboard/service/variables.tf | 8 ------ 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/dashboard/sections/grpc/grpc.tf b/dashboard/sections/grpc/grpc.tf index 95858b04..3425f122 100644 --- a/dashboard/sections/grpc/grpc.tf +++ b/dashboard/sections/grpc/grpc.tf @@ -1,7 +1,7 @@ variable "title" { type = string } variable "filter" { type = list(string) } variable "collapsed" { default = false } -variable "grpc_service_name" { type = string } +variable "service_name" { type = string } module "width" { source = "../width" } @@ -10,7 +10,7 @@ module "request_count" { 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}.*\")", + "resource.label.\"job\"=\"${var.service_name}\"", ]) group_by_fields = [ "metric.label.\"grpc_service\"", @@ -28,7 +28,38 @@ module "incoming_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}.*\")", + "resource.label.\"job\"=\"${var.service_name}\"", + ]) + group_by_fields = [ + "metric.label.\"grpc_service\"", + "metric.label.\"grpc_method\"", + ] +} + +module "outbound_request_count" { + source = "../../widgets/xy" + title = "Outbound request count" + filter = concat(var.filter, [ + "metric.type=\"prometheus.googleapis.com/grpc_client_handled_total/counter\"", + "resource.label.\"job\"=\"${var.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 = "Outbound request latency" + filter = concat(var.filter, [ + "metric.type=\"prometheus.googleapis.com/grpc_client_handling_seconds/histogram\"", + "resource.label.\"job\"=\"${var.service_name}\"", ]) group_by_fields = [ "metric.label.\"grpc_service\"", @@ -57,6 +88,18 @@ locals { height = local.unit, width = local.unit, widget = module.incoming_latency.widget, + }, { + yPos = local.unit + xPos = local.col[0], + height = local.unit, + width = local.unit, + widget = module.outbound_request_count.widget, + }, { + yPos = local.unit + xPos = local.col[1], + height = local.unit, + width = local.unit, + widget = module.outbound_latency.widget, }, ] } diff --git a/dashboard/service/README.md b/dashboard/service/README.md index ed417133..48a97893 100644 --- a/dashboard/service/README.md +++ b/dashboard/service/README.md @@ -77,7 +77,6 @@ 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 ffa7ef99..c91c4566 100644 --- a/dashboard/service/dashboard.tf +++ b/dashboard/service/dashboard.tf @@ -15,7 +15,7 @@ module "grpc" { source = "../sections/grpc" title = "GRPC" filter = [] - grpc_service_name = var.grpc_service_name + service_name = var.service_name } module "resources" { diff --git a/dashboard/service/variables.tf b/dashboard/service/variables.tf index 8fe62fe2..ba152ec4 100644 --- a/dashboard/service/variables.tf +++ b/dashboard/service/variables.tf @@ -14,11 +14,3 @@ 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 = "" -}