|
39 | 39 | ``` |
40 | 40 |
|
41 | 41 | ## Metrics |
| 42 | +[Metrics setup no docker](#metrics-setup-no-docker) |
42 | 43 |
|
| 44 | +[Metrics setup with docker](#metrics-setup-with-docker) |
| 45 | + |
| 46 | +## Metrics setup no docker |
43 | 47 | Prometheus maintains a database of metrics (trin & system). Grafana converts metrics into graphs. Node exporter provides system information. |
44 | 48 | ```mermaid |
45 | 49 | graph TD; |
@@ -234,7 +238,7 @@ This will serve metrics over port 3000. |
234 | 238 |
|
235 | 239 | Generate a grafana dashboard. From trin root directory: |
236 | 240 | ```sh |
237 | | -cargo run -p trin-cli -- create-dashboard |
| 241 | +cargo run -p trin -- create-dashboard http://localhost:3000 admin admin http://127.0.0.1:9090 |
238 | 242 | ``` |
239 | 243 | This will create a new monitoring database for trin. This will |
240 | 244 | be visible in the grafana GUI, or directly at a URL similar to: |
@@ -279,3 +283,31 @@ ssh -N -L 3000:127.0.0.1:3000 username@mycomputer |
279 | 283 | Then navigate to [http://127.0.0.1:3000](http://127.0.0.1:3000)` in a browser and login |
280 | 284 | with username: admin, password: admin. Then navigate to the trin-app-metrics dashboard. |
281 | 285 |
|
| 286 | +## Metrics setup with docker |
| 287 | +1. Install Docker. |
| 288 | +2. Run Prometheus, note that you MUST manually set the absolute path to your copy of Trin's `docs/metrics_config/`: |
| 289 | +```sh |
| 290 | +docker run -p 9090:9090 -v /**absolute/path/to/trin/docs/metrics_config**:/etc/prometheus --add-host=host.docker.internal:host-gateway prom/prometheus |
| 291 | +``` |
| 292 | +3. Run Grafana: |
| 293 | +```sh |
| 294 | +docker run -p 3000:3000 --add-host=host.docker.internal:host-gateway grafana/grafana:latest |
| 295 | +``` |
| 296 | +4. Start your Trin process with: |
| 297 | +```sh |
| 298 | +cargo run -p trin -- --enable-metrics-with-url 0.0.0.0:9100 --web3-http-address http://0.0.0.0:8545 --web3-transport http |
| 299 | +``` |
| 300 | +- The addresses must be bound to 0.0.0.0, because 127.0.0.1 only allows internal requests to |
| 301 | + complete, and requests from docker instances are considered external. |
| 302 | +- The `--enable-metrics-with-url` parameter is the address that Trin exports metrics to, and should be equal to the port to which your Prometheus server is targeting at the bottom of `metrics_config/prometheus.yml` |
| 303 | +- The `--web-transport http` will allow Grafana to request routing table information from Trin via JSON-RPC over HTTP |
| 304 | +5. From the root of the Trin repo, run `cargo run -p trin -- create-dashboard`. If you used different ports than detailed in the above steps, or you are not using docker, then this command's defaults will not work. Run the command with the `-h` flag to see how to provide non-default addresses or credentials. |
| 305 | +6. Upon successful dashboard creation, navigate to the dashboard URL that the `create-dashboard` outputs. Use `admin`/`admin` to login. |
| 306 | + |
| 307 | +## Gotchas |
| 308 | + |
| 309 | +- If `create-dashboard` fails with an error, the most likely reason is that it has already been run. From within the Grafana UI, delete the "json-rpc" and "prometheus" datasources and the "trin" dashboard and re-run the command. |
| 310 | + |
| 311 | +- There is a limit on concurrent connections given by the threadpool. At last |
| 312 | + doc update, that number was 2, but will surely change. If you leave |
| 313 | + connections open, then new connections will block. |
0 commit comments