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 gRPC (inbound) #37

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions dashboard/sections/grpc/grpc.tf
Original file line number Diff line number Diff line change
@@ -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" {
Comment on lines +39 to +57
Copy link
Member

Choose a reason for hiding this comment

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

These are unused?

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.*\")",
Copy link
Member

Choose a reason for hiding this comment

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

hmm chainguard.datastore here seems wrong.

])
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
}
2 changes: 2 additions & 0 deletions dashboard/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ No requirements.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_alerts"></a> [alerts](#module\_alerts) | ../sections/alerts | n/a |
| <a name="module_grpc"></a> [grpc](#module\_grpc) | ../sections/grpc | n/a |
| <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 |
Expand All @@ -70,6 +71,7 @@ No requirements.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_alerts"></a> [alerts](#input\_alerts) | Alerting policies to add to the dashboard. | `list(string)` | `[]` | no |
| <a name="input_grpc_service_name"></a> [grpc\_service\_name](#input\_grpc\_service\_name) | Name of the GRPC service(s) to monitor | `string` | `""` | no |
| <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 |

Expand Down
8 changes: 8 additions & 0 deletions dashboard/service/dashboard.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,6 +41,7 @@ module "layout" {
[
module.logs.section,
module.http.section,
module.grpc.section,
module.resources.section,
]
)
Expand Down
8 changes: 8 additions & 0 deletions dashboard/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should have a default here

}
Loading