feat: start Grafana and Prometheus when --metrics is passed#109
feat: start Grafana and Prometheus when --metrics is passed#109g11tech merged 4 commits intoblockblaz:mainfrom
--metrics is passed#109Conversation
There was a problem hiding this comment.
Pull request overview
Adds an optional local observability stack that is started/stopped via the existing --metrics flag, providing Prometheus scraping + Grafana dashboards during devnet runs.
Changes:
- Start/stop a Docker Compose Prometheus+Grafana stack when
--metricsis provided (including cleanup/stop handling). - Add scripts/config to generate Prometheus scrape targets from
validator-config.yamland provision Grafana dashboards/datasource. - Update README/docs and ignore generated
metrics/prometheus/prometheus.yml.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| spin-node.sh | Starts/stops metrics stack on --metrics for local runs and during cleanup/stop. |
| generate-prometheus-config.sh | Generates prometheus.yml scrape targets from validator-config.yaml. |
| metrics/docker-compose-metrics.yaml | Defines Prometheus + Grafana services for local monitoring. |
| metrics/grafana/provisioning/datasources/prometheus.yml | Provisions Grafana Prometheus datasource. |
| metrics/grafana/provisioning/dashboards/dashboards.yml | Provisions Grafana dashboards from the mounted dashboards directory. |
| metrics/grafana/dashboards/client-interop-dashboard.json | Adds prebuilt Grafana dashboard JSON. |
| metrics/grafana/dashboards/client-dashboard.json | Adds prebuilt Grafana dashboard JSON. |
| README.md | Documents the new --metrics behavior and URLs. |
| .gitignore | Ignores generated Prometheus config file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin | ||
| - GF_AUTH_DISABLE_LOGIN_FORM=true |
There was a problem hiding this comment.
Grafana is configured with anonymous access as Admin and the login form disabled. Even for local dev, this is a very permissive default (anyone who can reach port 3000 gets full admin capabilities, including adding datasources/plugins). Consider setting the anonymous role to Viewer (or Editor) and/or keeping the login form enabled, and document the default credentials if admin access is needed.
| - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin | |
| - GF_AUTH_DISABLE_LOGIN_FORM=true | |
| - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer | |
| - GF_AUTH_DISABLE_LOGIN_FORM=false |
There was a problem hiding this comment.
I think admin access without login is not a problem for a local devnet
- Use explicit UID for prometheus datasource - Fix counting issue in log on prom config generation - Pin Grafana and Prometheus images - Add host.docker.internal mapping for Linux users
This PR changes the
--metricsflag to specify if a Grafana stack for metrics collection should be started. Adding a default Grafana+Prometheus to this repo improves observability during local devnet runs.The Grafana dashboards are the ones from leanMetrics: https://github.com/leanEthereum/leanMetrics/tree/main/development
I replaced the existing
--metricsflag with the new functionality since it wasn't being used: specifying it was supposed to enable metrics in clients, but they were already enabled by default. As an alternative, we could keep the old documentation, but adding information about the new stack, or introduce a new flag (like--collect-metrics).