-
Notifications
You must be signed in to change notification settings - Fork 74
Add Cloud Monitoring dashboard for ATE gRPC server metrics #130
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Cloud Monitoring dashboards | ||
|
|
||
| Google Cloud Monitoring dashboard definitions for ATE. They turn the raw | ||
| `prometheus.googleapis.com/...` metrics that ATE emits into readable | ||
| per-method latency / throughput / error views. | ||
|
|
||
| | File | Shows | | ||
| |------|-------| | ||
| | `ate-grpc-dashboard.json` | ateapi & atelet gRPC latency (p50/p95/p99), request rate, and error rate, by method | | ||
|
|
||
| ## Applying | ||
|
|
||
| Dashboards are created/updated (idempotently) by setup: | ||
|
|
||
| ```sh | ||
| go run ./tools/setup-gcp --create-monitoring-dashboards # also part of: --all | ||
| ``` | ||
|
|
||
| Or apply any single file by hand: | ||
|
|
||
| ```sh | ||
| gcloud monitoring dashboards create --config-from-file=monitoring/dashboards/<file>.json | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| { | ||
| "displayName": "ATE gRPC Server — latency / QPS / errors", | ||
| "mosaicLayout": { | ||
| "columns": 12, | ||
| "tiles": [ | ||
| { | ||
| "xPos": 0, | ||
| "yPos": 0, | ||
| "width": 6, | ||
| "height": 4, | ||
| "widget": { | ||
| "title": "ateapi — gRPC p99 latency by method", | ||
| "xyChart": { | ||
| "dataSets": [ | ||
| { | ||
| "timeSeriesQuery": { | ||
| "prometheusQuery": "histogram_quantile(0.99, sum by (le, \"rpc.method\") (rate({\"rpc.server.call.duration_bucket\", top_level_controller_name=\"ate-api-server-deployment\"}[5m])))", | ||
| "unitOverride": "s" | ||
| }, | ||
| "plotType": "LINE", | ||
| "targetAxis": "Y1" | ||
| } | ||
| ], | ||
| "yAxis": { | ||
| "label": "seconds", | ||
| "scale": "LINEAR" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "xPos": 0, | ||
| "yPos": 4, | ||
| "width": 6, | ||
| "height": 4, | ||
| "widget": { | ||
| "title": "ateapi — gRPC request rate by method (req/s)", | ||
| "xyChart": { | ||
| "dataSets": [ | ||
| { | ||
| "timeSeriesQuery": { | ||
| "prometheusQuery": "sum by (\"rpc.method\") (rate({\"rpc.server.call.duration_count\", top_level_controller_name=\"ate-api-server-deployment\"}[5m]))", | ||
| "unitOverride": "1/s" | ||
| }, | ||
| "plotType": "LINE", | ||
| "targetAxis": "Y1" | ||
| } | ||
| ], | ||
| "yAxis": { | ||
| "label": "requests/s", | ||
| "scale": "LINEAR" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "xPos": 0, | ||
| "yPos": 8, | ||
| "width": 6, | ||
| "height": 4, | ||
| "widget": { | ||
| "title": "ateapi — gRPC errors by status code (req/s, non-OK)", | ||
| "xyChart": { | ||
| "dataSets": [ | ||
| { | ||
| "timeSeriesQuery": { | ||
| "prometheusQuery": "sum by (\"rpc.response.status_code\") (rate({\"rpc.server.call.duration_count\", top_level_controller_name=\"ate-api-server-deployment\", \"rpc.response.status_code\"!=\"OK\"}[5m]))", | ||
| "unitOverride": "1/s" | ||
| }, | ||
| "plotType": "LINE", | ||
| "targetAxis": "Y1" | ||
| } | ||
| ], | ||
| "yAxis": { | ||
| "label": "errors/s", | ||
| "scale": "LINEAR" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "xPos": 6, | ||
| "yPos": 0, | ||
| "width": 6, | ||
| "height": 4, | ||
| "widget": { | ||
| "title": "atelet — gRPC p99 latency by method", | ||
| "xyChart": { | ||
| "dataSets": [ | ||
| { | ||
| "timeSeriesQuery": { | ||
| "prometheusQuery": "histogram_quantile(0.99, sum by (le, \"rpc.method\") (rate({\"rpc.server.call.duration_bucket\", top_level_controller_name=\"atelet\"}[5m])))", | ||
| "unitOverride": "s" | ||
| }, | ||
| "plotType": "LINE", | ||
| "targetAxis": "Y1" | ||
| } | ||
| ], | ||
| "yAxis": { | ||
| "label": "seconds", | ||
| "scale": "LINEAR" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "xPos": 6, | ||
| "yPos": 4, | ||
| "width": 6, | ||
| "height": 4, | ||
| "widget": { | ||
| "title": "atelet — gRPC request rate by method (req/s)", | ||
| "xyChart": { | ||
| "dataSets": [ | ||
| { | ||
| "timeSeriesQuery": { | ||
| "prometheusQuery": "sum by (\"rpc.method\") (rate({\"rpc.server.call.duration_count\", top_level_controller_name=\"atelet\"}[5m]))", | ||
| "unitOverride": "1/s" | ||
| }, | ||
| "plotType": "LINE", | ||
| "targetAxis": "Y1" | ||
| } | ||
| ], | ||
| "yAxis": { | ||
| "label": "requests/s", | ||
| "scale": "LINEAR" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "xPos": 6, | ||
| "yPos": 8, | ||
| "width": 6, | ||
| "height": 4, | ||
| "widget": { | ||
| "title": "atelet — gRPC errors by status code (req/s, non-OK)", | ||
| "xyChart": { | ||
| "dataSets": [ | ||
| { | ||
| "timeSeriesQuery": { | ||
| "prometheusQuery": "sum by (\"rpc.response.status_code\") (rate({\"rpc.server.call.duration_count\", top_level_controller_name=\"atelet\", \"rpc.response.status_code\"!=\"OK\"}[5m]))", | ||
| "unitOverride": "1/s" | ||
| }, | ||
| "plotType": "LINE", | ||
| "targetAxis": "Y1" | ||
| } | ||
| ], | ||
| "yAxis": { | ||
| "label": "errors/s", | ||
| "scale": "LINEAR" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // Copyright 2026 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package cmd | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "log/slog" | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| dashboard "cloud.google.com/go/monitoring/dashboard/apiv1" | ||
| "cloud.google.com/go/monitoring/dashboard/apiv1/dashboardpb" | ||
| "google.golang.org/api/iterator" | ||
| "google.golang.org/protobuf/encoding/protojson" | ||
| ) | ||
|
|
||
| // dashboardsToApply lists the Cloud Monitoring dashboard JSON files (relative to | ||
| // the repo root, so run setup from the repo root) that setup creates or updates. | ||
| var dashboardsToApply = []string{ | ||
| "monitoring/dashboards/ate-grpc-dashboard.json", | ||
| } | ||
|
|
||
| // createMonitoringDashboards creates or updates each dashboard in | ||
| // dashboardsToApply. It is idempotent: dashboards are matched by displayName and | ||
| // updated in place, because CreateDashboard always creates a new dashboard (so | ||
| // calling it repeatedly would produce duplicates). | ||
| func createMonitoringDashboards(ctx context.Context, env *Environment) error { | ||
| client, err := dashboard.NewDashboardsClient(ctx) | ||
| if err != nil { | ||
| return fmt.Errorf("create dashboards client: %w", err) | ||
| } | ||
| defer client.Close() | ||
|
|
||
| parent := "projects/" + env.ProjectID | ||
|
|
||
| // Index existing dashboards by displayName to decide create vs update. | ||
| existing := map[string]*dashboardpb.Dashboard{} | ||
| it := client.ListDashboards(ctx, &dashboardpb.ListDashboardsRequest{Parent: parent}) | ||
| for { | ||
| d, err := it.Next() | ||
| if err == iterator.Done { | ||
| break | ||
| } | ||
| if err != nil { | ||
| return fmt.Errorf("list dashboards: %w", err) | ||
| } | ||
| existing[d.GetDisplayName()] = d | ||
| } | ||
|
|
||
| for _, path := range dashboardsToApply { | ||
| data, err := os.ReadFile(path) | ||
| if err != nil { | ||
| return fmt.Errorf("read %s: %w", path, err) | ||
| } | ||
| d := &dashboardpb.Dashboard{} | ||
| if err := protojson.Unmarshal(data, d); err != nil { | ||
| return fmt.Errorf("parse %s: %w", path, err) | ||
| } | ||
|
|
||
| if cur, ok := existing[d.GetDisplayName()]; ok { | ||
| // Update in place: reuse the existing resource name and etag. | ||
| d.Name = cur.GetName() | ||
| d.Etag = cur.GetEtag() | ||
| slog.Info("Updating dashboard", | ||
| slog.String("displayName", d.GetDisplayName()), | ||
| slog.String("name", d.GetName()), | ||
| slog.String("file", filepath.Base(path))) | ||
| if _, err := client.UpdateDashboard(ctx, &dashboardpb.UpdateDashboardRequest{Dashboard: d}); err != nil { | ||
| return fmt.Errorf("update dashboard %q: %w", d.GetDisplayName(), err) | ||
| } | ||
| } else { | ||
| slog.Info("Creating dashboard", | ||
| slog.String("displayName", d.GetDisplayName()), | ||
| slog.String("file", filepath.Base(path))) | ||
| if _, err := client.CreateDashboard(ctx, &dashboardpb.CreateDashboardRequest{Parent: parent, Dashboard: d}); err != nil { | ||
| return fmt.Errorf("create dashboard %q: %w", d.GetDisplayName(), err) | ||
| } | ||
| } | ||
| } | ||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this only work on GCP? We might want to refactor at some point to split them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes for now, we need to configure all dashboards we add for Cloud Monitoring also to OSS (e.g. Grafana).