diff --git a/README.md b/README.md index c61ae52..6665665 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,10 @@ user_fee_token_deployer: 0x2AC5278D230f88B481bBE4A94751d7188ef48Ca2 While not a named account, 0x3f1eae7d46d88f08fc2f8ed27fcb2ab183eb2d0e is funded on all test chains. +## Metrics + +To run the metrics stack (Prometheus + Grafana) read the instructions in the [metrics/README.md](metrics/README.md) file. + ## Contact Discord - [Arbitrum](https://discord.com/invite/5KE54JwyTs) diff --git a/metrics/README.md b/metrics/README.md new file mode 100644 index 0000000..7e7a6aa --- /dev/null +++ b/metrics/README.md @@ -0,0 +1,36 @@ +# Arbitrum Nitro Metrics + +You can run this docker compose file it will run + +- prometheus +- grafana +- setup the default dashboard + +The default username/password is `admin`/`admin`. + +## Run the metrics services + +Simply start docker compose in this `metrics/` folder: + +```sh +docker compose up +``` + +## Enable metrics on Nitro node + +Don't forget to run the Nitro node with metrics exporting on, to do so add the following flags to your Nitro node startup command: + +```sh +--metrics --metrics-server.addr=0.0.0.0 +``` + +> ⚠️ Warning: Using 0.0.0.0 is recommended for cross-platform compatibility, +especially when accessing metrics from Docker, Linux, WSL, or remote containers. + +## View the Dashboard + +View the dashboard at http://localhost:3000 + +## How to add more grafana dashboards + +To add more grafana dashboards you can drop json files into the `grafana/dashboards/` folder. \ No newline at end of file diff --git a/metrics/compose.yml b/metrics/compose.yml new file mode 100644 index 0000000..88db959 --- /dev/null +++ b/metrics/compose.yml @@ -0,0 +1,31 @@ +services: + prometheus: + image: prom/prometheus + container_name: prometheus + command: + - '--config.file=/etc/prometheus/prometheus.yaml' + restart: unless-stopped + volumes: + - ./prometheus:/etc/prometheus + - prometheus_data:/prometheus + ports: + - 9090:9090 + extra_hosts: + - "host.docker.internal:host-gateway" + grafana: + image: grafana/grafana + container_name: grafana + restart: unless-stopped + volumes: + - ./grafana/datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml + - ./grafana/dashboard.yaml:/etc/grafana/provisioning/dashboards/main.yaml + - ./grafana/dashboards:/var/lib/grafana/dashboards + ports: + - 3000:3000 + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + prometheus_data: + +networks: {} diff --git a/metrics/grafana/dashboard.yaml b/metrics/grafana/dashboard.yaml new file mode 100644 index 0000000..5381f8b --- /dev/null +++ b/metrics/grafana/dashboard.yaml @@ -0,0 +1,12 @@ +apiVersion: 1 + +providers: + - name: "Offchain Labs" + orgId: 1 + type: file + disableDeletion: false + updateIntervalSeconds: 10 + allowUiUpdates: false + options: + path: /var/lib/grafana/dashboards + foldersFromFilesStructure: true diff --git a/metrics/grafana/dashboards/example.json b/metrics/grafana/dashboards/example.json new file mode 100644 index 0000000..cbf5e27 --- /dev/null +++ b/metrics/grafana/dashboards/example.json @@ -0,0 +1 @@ +{"annotations":{"list":[{"builtIn":1,"datasource":{"type":"grafana","uid":"-- Grafana --"},"enable":true,"hide":true,"iconColor":"rgba(0, 211, 255, 1)","name":"Annotations & Alerts","type":"dashboard"}]},"editable":true,"fiscalYearStartMonth":0,"graphTooltip":0,"id":0,"links":[],"panels":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"fieldConfig":{"defaults":{"color":{"mode":"palette-classic"},"custom":{"axisBorderShow":false,"axisCenteredZero":false,"axisColorMode":"text","axisLabel":"","axisPlacement":"auto","barAlignment":0,"barWidthFactor":0.6,"drawStyle":"line","fillOpacity":0,"gradientMode":"none","hideFrom":{"legend":false,"tooltip":false,"viz":false},"insertNulls":false,"lineInterpolation":"linear","lineWidth":1,"pointSize":5,"scaleDistribution":{"type":"linear"},"showPoints":"auto","showValues":false,"spanNulls":false,"stacking":{"group":"A","mode":"none"},"thresholdsStyle":{"mode":"off"}},"mappings":[],"thresholds":{"mode":"absolute","steps":[{"color":"green","value":0},{"color":"red","value":80}]}},"overrides":[]},"gridPos":{"h":8,"w":12,"x":0,"y":0},"id":1,"options":{"legend":{"calcs":[],"displayMode":"list","placement":"bottom","showLegend":true},"tooltip":{"hideZeros":false,"mode":"single","sort":"none"}},"pluginVersion":"12.2.0","targets":[{"datasource":{"type":"prometheus","uid":"PBFA97CFB590B2093"},"editorMode":"builder","expr":"arb_block_transactions_count","legendFormat":"__auto","range":true,"refId":"A"}],"title":"Arb Block Transactions Count","type":"timeseries"}],"preload":false,"refresh":"5s","schemaVersion":42,"tags":[],"templating":{"list":[]},"time":{"from":"now-30m","to":"now"},"timepicker":{},"timezone":"browser","title":"Example dashboard","uid":"adq7lsl","version":2} \ No newline at end of file diff --git a/metrics/grafana/datasource.yaml b/metrics/grafana/datasource.yaml new file mode 100644 index 0000000..458e79f --- /dev/null +++ b/metrics/grafana/datasource.yaml @@ -0,0 +1,9 @@ +apiVersion: 1 + +datasources: +- name: Prometheus + type: prometheus + url: http://host.docker.internal:9090 + isDefault: true + access: proxy + editable: true diff --git a/metrics/prometheus/prometheus.yaml b/metrics/prometheus/prometheus.yaml new file mode 100644 index 0000000..2ad3084 --- /dev/null +++ b/metrics/prometheus/prometheus.yaml @@ -0,0 +1,13 @@ +global: + scrape_interval: 4s + scrape_timeout: 4s + evaluation_interval: 10s + +scrape_configs: + - job_name: "nitro" + metrics_path: /debug/metrics/prometheus + static_configs: + - targets: + - host.docker.internal:6070 + labels: + instance: local_node