Skip to content

Commit

Permalink
Add outbound HTTP dashboard
Browse files Browse the repository at this point in the history
Signed-off-by: Nghia Tran <[email protected]>
  • Loading branch information
tcnghia committed Dec 22, 2023
1 parent acde85a commit b2640b8
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 11 deletions.
64 changes: 57 additions & 7 deletions dashboard/sections/http/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
variable "title" { type = string }
variable "filter" { type = list(string) }
variable "collapsed" { default = false }
variable "service_name" { type = string }

module "width" { source = "../width" }

Expand All @@ -21,7 +22,42 @@ module "incoming_latency" {
filter = concat(var.filter, ["metric.type=\"run.googleapis.com/request_latencies\""])
}

locals {
// gmp_filter is a subset of var.filter that does not include the "resource.type" string
gmp_filter = [for f in var.filter : f if !strcontains(f, "resource.type")]
}

output "gmp_filter" {
value = local.gmp_filter
}

output "var_filter" {
value = var.filter
}

// TODO(mattmoor): output HTTP charts.
module "outbound_request_count" {
source = "../../widgets/xy"
title = "Outbound Request count"
filter = concat(local.gmp_filter, [
"metric.type=\"prometheus.googleapis.com/http_client_request_count_total/counter\"",
"metric.label.service_name=\"${var.service_name}\"",
])
group_by_fields = [
"metric.label.\"code\"",
"metric.label.\"host\"",
]
primary_align = "ALIGN_RATE"
primary_reduce = "REDUCE_NONE"
secondary_align = "ALIGN_NONE"
secondary_reduce = "REDUCE_SUM"
}

module "outbound_request_latency" {
source = "../../widgets/latency"
title = "Outbound request latency"
filter = concat(local.gmp_filter, ["metric.type=\"prometheus.googleapis.com/http_client_request_duration_seconds/histogram\""])
}

locals {
columns = 2
Expand All @@ -37,13 +73,27 @@ locals {
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,
},
{
yPos = 0
xPos = local.col[1],
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_request_latency.widget,
}]
}

Expand Down
9 changes: 5 additions & 4 deletions dashboard/service/dashboard.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ module "logs" {
}

module "http" {
source = "../sections/http"
title = "HTTP"
filter = ["resource.type=\"cloud_run_revision\""]
source = "../sections/http"
title = "HTTP"
filter = ["resource.type=\"cloud_run_revision\""]
service_name = var.service_name
}

module "resources" {
Expand All @@ -19,7 +20,7 @@ module "resources" {
module "width" { source = "../sections/width" }

module "layout" {
source = "../sections/layout"
source = "../sections/layout"
sections = [
module.logs.section,
module.http.section,
Expand Down

0 comments on commit b2640b8

Please sign in to comment.