Skip to content

Commit baf1786

Browse files
Add an optional agents section to dashboards. (#1213)
Signed-off-by: Matt Moore <[email protected]> Co-authored-by: octo-sts[bot] <157150467+octo-sts[bot]@users.noreply.github.com>
1 parent 06c8ccc commit baf1786

File tree

8 files changed

+170
-2
lines changed

8 files changed

+170
-2
lines changed

modules/dashboard/reconciler/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ No providers.
9494
9595
| Name | Source | Version |
9696
|------|--------|---------|
97+
| <a name="module_agents"></a> [agents](#module\_agents) | ../sections/agents | n/a |
9798
| <a name="module_alerts"></a> [alerts](#module\_alerts) | ../sections/alerts | n/a |
9899
| <a name="module_dashboard"></a> [dashboard](#module\_dashboard) | ../ | n/a |
99100
| <a name="module_errgrp"></a> [errgrp](#module\_errgrp) | ../sections/errgrp | n/a |
@@ -121,7 +122,7 @@ No resources.
121122
| <a name="input_name"></a> [name](#input\_name) | The name of the reconciler (base name without suffixes) | `string` | n/a | yes |
122123
| <a name="input_notification_channels"></a> [notification\_channels](#input\_notification\_channels) | List of notification channels for alerts | `list(string)` | `[]` | no |
123124
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | The GCP project ID | `string` | n/a | yes |
124-
| <a name="input_sections"></a> [sections](#input\_sections) | Configure visibility of optional dashboard sections | <pre>object({<br/> github = optional(bool, false)<br/> })</pre> | `{}` | no |
125+
| <a name="input_sections"></a> [sections](#input\_sections) | Configure visibility of optional dashboard sections | <pre>object({<br/> github = optional(bool, false)<br/> agents = optional(bool, false)<br/> })</pre> | `{}` | no |
125126
| <a name="input_service_name"></a> [service\_name](#input\_service\_name) | The name of the reconciler service (defaults to name-rec) | `string` | `""` | no |
126127
| <a name="input_workqueue_name"></a> [workqueue\_name](#input\_workqueue\_name) | The name of the workqueue (defaults to name-wq) | `string` | `""` | no |
127128

modules/dashboard/reconciler/dashboard.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ module "github" {
5656
filter = []
5757
}
5858

59+
module "agents" {
60+
source = "../sections/agents"
61+
title = "Agent Metrics"
62+
filter = [
63+
"metric.label.\"service_name\"=\"${local.service_name}\""
64+
]
65+
}
66+
5967
module "resources" {
6068
source = "../sections/resources"
6169
title = "Reconciler Resources"
@@ -87,6 +95,7 @@ module "layout" {
8795
module.grpc.section,
8896
],
8997
var.sections.github ? [module.github.section] : [],
98+
var.sections.agents ? [module.agents.section] : [],
9099
[module.resources.section],
91100
)
92101
}

modules/dashboard/reconciler/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ variable "sections" {
4343
description = "Configure visibility of optional dashboard sections"
4444
type = object({
4545
github = optional(bool, false)
46+
agents = optional(bool, false)
4647
})
4748
default = {}
4849
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
## Requirements
3+
4+
No requirements.
5+
6+
## Providers
7+
8+
No providers.
9+
10+
## Modules
11+
12+
| Name | Source | Version |
13+
|------|--------|---------|
14+
| <a name="module_collapsible"></a> [collapsible](#module\_collapsible) | ../collapsible | n/a |
15+
| <a name="module_evaluation_failure_rate"></a> [evaluation\_failure\_rate](#module\_evaluation\_failure\_rate) | ../../widgets/xy-ratio | n/a |
16+
| <a name="module_evaluation_grade_p99"></a> [evaluation\_grade\_p99](#module\_evaluation\_grade\_p99) | ../../widgets/xy | n/a |
17+
| <a name="module_evaluation_volume"></a> [evaluation\_volume](#module\_evaluation\_volume) | ../../widgets/xy | n/a |
18+
| <a name="module_width"></a> [width](#module\_width) | ../width | n/a |
19+
20+
## Resources
21+
22+
No resources.
23+
24+
## Inputs
25+
26+
| Name | Description | Type | Default | Required |
27+
|------|-------------|------|---------|:--------:|
28+
| <a name="input_collapsed"></a> [collapsed](#input\_collapsed) | n/a | `bool` | `false` | no |
29+
| <a name="input_filter"></a> [filter](#input\_filter) | n/a | `list(string)` | n/a | yes |
30+
| <a name="input_title"></a> [title](#input\_title) | n/a | `string` | n/a | yes |
31+
32+
## Outputs
33+
34+
| Name | Description |
35+
|------|-------------|
36+
| <a name="output_section"></a> [section](#output\_section) | n/a |
37+
<!-- END_TF_DOCS -->
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
Copyright 2025 Chainguard, Inc.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
variable "title" { type = string }
7+
variable "filter" { type = list(string) }
8+
variable "collapsed" { default = false }
9+
module "width" { source = "../width" }
10+
11+
module "evaluation_volume" {
12+
source = "../../widgets/xy"
13+
title = "Agent evaluation volume"
14+
filter = concat(var.filter, [
15+
"metric.type=\"prometheus.googleapis.com/agent_evaluations_total/counter\"",
16+
])
17+
18+
group_by_fields = [
19+
"metric.label.\"tracer_type\"",
20+
"metric.label.\"namespace\"",
21+
]
22+
primary_align = "ALIGN_RATE"
23+
primary_reduce = "REDUCE_SUM"
24+
}
25+
26+
module "evaluation_failure_rate" {
27+
source = "../../widgets/xy-ratio"
28+
title = "Agent evaluation failure rate"
29+
30+
numerator_filter = concat(var.filter, [
31+
"metric.type=\"prometheus.googleapis.com/agent_evaluation_failures_total/counter\"",
32+
])
33+
denominator_filter = concat(var.filter, [
34+
"metric.type=\"prometheus.googleapis.com/agent_evaluations_total/counter\"",
35+
])
36+
37+
numerator_group_by_fields = [
38+
"metric.label.\"tracer_type\"",
39+
"metric.label.\"namespace\"",
40+
]
41+
denominator_group_by_fields = [
42+
"metric.label.\"tracer_type\"",
43+
"metric.label.\"namespace\"",
44+
]
45+
46+
numerator_align = "ALIGN_RATE"
47+
numerator_reduce = "REDUCE_SUM"
48+
denominator_align = "ALIGN_RATE"
49+
denominator_reduce = "REDUCE_SUM"
50+
}
51+
52+
module "evaluation_grade_p99" {
53+
source = "../../widgets/xy"
54+
title = "Agent evaluation grade (P99)"
55+
filter = concat(var.filter, [
56+
"metric.type=\"prometheus.googleapis.com/agent_evaluation_grade/gauge\"",
57+
])
58+
59+
group_by_fields = [
60+
"metric.label.\"tracer_type\"",
61+
"metric.label.\"namespace\"",
62+
]
63+
primary_align = "ALIGN_MEAN"
64+
primary_reduce = "REDUCE_PERCENTILE_99"
65+
}
66+
67+
locals {
68+
columns = 3
69+
unit = module.width.size / local.columns
70+
71+
col = range(0, local.columns * local.unit, local.unit)
72+
73+
tiles = [
74+
{
75+
yPos = local.unit,
76+
xPos = local.col[0],
77+
height = local.unit,
78+
width = local.unit,
79+
widget = module.evaluation_volume.widget,
80+
},
81+
{
82+
yPos = local.unit,
83+
xPos = local.col[1],
84+
height = local.unit,
85+
width = local.unit,
86+
widget = module.evaluation_failure_rate.widget,
87+
},
88+
{
89+
yPos = local.unit,
90+
xPos = local.col[2],
91+
height = local.unit,
92+
width = local.unit,
93+
widget = module.evaluation_grade_p99.widget,
94+
},
95+
]
96+
}
97+
98+
module "collapsible" {
99+
source = "../collapsible"
100+
101+
title = var.title
102+
tiles = local.tiles
103+
collapsed = var.collapsed
104+
}
105+
106+
output "section" {
107+
value = module.collapsible.section
108+
}

modules/dashboard/service/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ No providers.
5959

6060
| Name | Source | Version |
6161
|------|--------|---------|
62+
| <a name="module_agents"></a> [agents](#module\_agents) | ../sections/agents | n/a |
6263
| <a name="module_alerts"></a> [alerts](#module\_alerts) | ../sections/alerts | n/a |
6364
| <a name="module_dashboard"></a> [dashboard](#module\_dashboard) | ../ | n/a |
6465
| <a name="module_errgrp"></a> [errgrp](#module\_errgrp) | ../sections/errgrp | n/a |
@@ -83,7 +84,7 @@ No resources.
8384
| <a name="input_labels"></a> [labels](#input\_labels) | Additional labels to apply to the dashboard. | `map` | `{}` | no |
8485
| <a name="input_notification_channels"></a> [notification\_channels](#input\_notification\_channels) | List of notification channels to alert. | `list(string)` | n/a | yes |
8586
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | ID of the GCP project | `string` | n/a | yes |
86-
| <a name="input_sections"></a> [sections](#input\_sections) | Sections to include in the dashboard | <pre>object({<br/> http = optional(bool, true) // Include HTTP section<br/> grpc = optional(bool, true) // Include GRPC section<br/> github = optional(bool, false) // Include GitHub API section<br/> gorm = optional(bool, false) // Include GORM section<br/> })</pre> | <pre>{<br/> "github": false,<br/> "gorm": false,<br/> "grpc": true,<br/> "http": true<br/>}</pre> | no |
87+
| <a name="input_sections"></a> [sections](#input\_sections) | Sections to include in the dashboard | <pre>object({<br/> http = optional(bool, true) // Include HTTP section<br/> grpc = optional(bool, true) // Include GRPC section<br/> github = optional(bool, false) // Include GitHub API section<br/> gorm = optional(bool, false) // Include GORM section<br/> agents = optional(bool, false) // Include Agent metrics section<br/> })</pre> | <pre>{<br/> "agents": false,<br/> "github": false,<br/> "gorm": false,<br/> "grpc": true,<br/> "http": true<br/>}</pre> | no |
8788
| <a name="input_service_name"></a> [service\_name](#input\_service\_name) | Name of the service(s) to monitor | `string` | n/a | yes |
8889

8990
## Outputs

modules/dashboard/service/dashboard.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ module "gorm" {
3939
service_name = var.service_name
4040
}
4141

42+
module "agents" {
43+
source = "../sections/agents"
44+
title = "Agent Metrics"
45+
filter = [
46+
"metric.label.\"service_name\"=\"${var.service_name}\""
47+
]
48+
}
49+
4250
module "resources" {
4351
source = "../sections/resources"
4452
title = "Resources"
@@ -70,6 +78,7 @@ module "layout" {
7078
var.sections.grpc ? [module.grpc.section] : [],
7179
var.sections.github ? [module.github.section] : [],
7280
var.sections.gorm ? [module.gorm.section] : [],
81+
var.sections.agents ? [module.agents.section] : [],
7382
[module.resources.section],
7483
)
7584
}

modules/dashboard/service/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ variable "sections" {
3131
grpc = optional(bool, true) // Include GRPC section
3232
github = optional(bool, false) // Include GitHub API section
3333
gorm = optional(bool, false) // Include GORM section
34+
agents = optional(bool, false) // Include Agent metrics section
3435
})
3536
default = {
3637
http = true
3738
grpc = true
3839
github = false
3940
gorm = false
41+
agents = false
4042
}
4143
}

0 commit comments

Comments
 (0)