From 757d224fd7692a4deccbec8729548146e9b7f295 Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Mon, 10 Jun 2024 14:24:59 -0700 Subject: [PATCH] fix: metrics dev-env for linux Fixes a hardcoded path in the compose setup for local metrics. Updates the docs, as well, to clarify that the first-run experience via docker compose is only relevant for Linux hosts, due to use of host-networking. Will work on a macos-compatible dev env later, but for now focusing on making sure what's in the repo is clear and runnable for actual testnet node operators, which means Linux boxes. Closes #4565. --- deployments/compose/justfile | 3 --- deployments/compose/metrics.yml | 7 +++++++ deployments/config/prometheus.yml | 2 +- deployments/containerfiles/Dockerfile-grafana | 4 ++-- docs/guide/src/dev/metrics.md | 12 +++++++----- justfile | 5 +++++ 6 files changed, 22 insertions(+), 11 deletions(-) delete mode 100644 deployments/compose/justfile diff --git a/deployments/compose/justfile b/deployments/compose/justfile deleted file mode 100644 index 85067b067e..0000000000 --- a/deployments/compose/justfile +++ /dev/null @@ -1,3 +0,0 @@ -# Run a grafana/prometheus sidecar deployment, attaching to local node. -metrics: - docker-compose -f metrics.yml up --build --abort-on-container-exit --force-recreate diff --git a/deployments/compose/metrics.yml b/deployments/compose/metrics.yml index 32343a156c..9b2e391aee 100644 --- a/deployments/compose/metrics.yml +++ b/deployments/compose/metrics.yml @@ -13,10 +13,17 @@ services: dockerfile: deployments/containerfiles/Dockerfile-grafana network_mode: host user: "${UID:-1000}" + # Don't use ports, since ports conflicts with network_mode=host. + # We use network_mode=host so that metrics can talk to services bound + # to localhost. + # ports: + # - "3000:3000" # The Prometheus service, for scraping metrics from Penumbra's pd metrics port. prom: image: "docker.io/prom/prometheus" network_mode: host + # ports: + # - "9090:9090" volumes: - "${PWD:?}/../config/prometheus.yml:/etc/prometheus/prometheus.yml:ro" diff --git a/deployments/config/prometheus.yml b/deployments/config/prometheus.yml index b19d6a4241..1a6b081751 100644 --- a/deployments/config/prometheus.yml +++ b/deployments/config/prometheus.yml @@ -1,5 +1,5 @@ scrape_configs: - - job_name: 'Tendermint Node' + - job_name: 'CometBFT Node' scrape_interval: 10s scheme: http metrics_path: metrics diff --git a/deployments/containerfiles/Dockerfile-grafana b/deployments/containerfiles/Dockerfile-grafana index 09dca43e20..dbf77781c8 100644 --- a/deployments/containerfiles/Dockerfile-grafana +++ b/deployments/containerfiles/Dockerfile-grafana @@ -1,5 +1,5 @@ ARG GRAFANA_VERSION="10.1.5" FROM docker.io/grafana/grafana:${GRAFANA_VERSION} -COPY deployments/config/grafana/provisioning /etc/grafana/provisioning +COPY deployments/config/grafana/provisioning/ /etc/grafana/provisioning/ COPY deployments/config/grafana/grafana.ini /etc/grafana/grafana.ini -COPY deployments/config/grafana/dashboards /var/lib/grafana/dashboards +COPY deployments/config/grafana/dashboards/ /var/lib/grafana/dashboards/ diff --git a/docs/guide/src/dev/metrics.md b/docs/guide/src/dev/metrics.md index e30f58252e..45597b327d 100644 --- a/docs/guide/src/dev/metrics.md +++ b/docs/guide/src/dev/metrics.md @@ -62,10 +62,10 @@ After being changed, Grafana dashboards should be backed up to the repository fo Grafana has an [import/export](https://grafana.com/docs/grafana/latest/dashboards/export-import/) feature that we use for maintaining our dashboards. -1. Export the dashboard as JSON with the default settings -2. Rename the JSON file and copy into the repo (`config/grafana/dashboards/`) -3. PR the changes into main, and confirm on preview post-deploy that it works as expected. - +1. View the dashboard you want to export, and click the share icon in the top bar. +2. Choose **Export**, and enable **Export for sharing externally**, which will generalized the datasource. +3. Download the JSON file, renaming it as necessary, and copy into the repo (`config/grafana/dashboards/`) +4. PR the changes into main, and confirm on preview post-deploy that it works as expected. ## Editing metrics locally @@ -73,9 +73,11 @@ To facilitate working with metrics locally, first run a `pd` node on your machin exposed. Then, you can spin up a metrics sidecar deployment: ```bash -cd deployments/compose just metrics ``` +Note that this setup only works on Linux hosts, due to the use of host networking, so the metrics +containers can reach network ports on the host machine. + To add new Grafana visualizations, open http://localhost:3000 and edit the existing dashboards. When you're happy with what you've got, follow the "Backing up Grafana" instructions above to save your work. diff --git a/justfile b/justfile index 70b9b61aaa..ae95bb130f 100644 --- a/justfile +++ b/justfile @@ -10,6 +10,11 @@ fmt: proto: ./deployments/scripts/protobuf-codegen +# Run a local prometheus/grafana setup, in containers, to scrape a local node. Linux only. +metrics: + cd ./deployments/compose/ \ + && docker-compose -f metrics.yml up --build --abort-on-container-exit --force-recreate --remove-orphans + # Configures and runs a relayer instance between "preview" (latest main) and local devnet on current HEAD relayer-local-devnet: ./deployments/scripts/relayer-local-devnet