Skip to content

Commit

Permalink
chore(monitoring): docker compose configuration for Grafana & Prometh…
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin authored Feb 17, 2023
1 parent 54b6a4a commit 4e31c89
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 3 deletions.
16 changes: 15 additions & 1 deletion etc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,18 @@ The files in this directory may undergo a lot of changes while reth is unstable,
### Overview

- [**Prometheus**](./prometheus/prometheus.yml): An example Prometheus configuration.
- [**Grafana**](./grafana/): Example Grafana dashboards.
- [**Grafana**](./grafana/): Example Grafana dashboards & data sources.

### Docker Compose

To run Grafana dashboard with example dashboard and pre-configured Prometheus data source pointing at
the locally running Reth instance with metrics exposed on `localhost:9000`:
```sh
docker compose -p reth -f ./etc/docker-monitoring.yml up
```

After that, Grafana will be exposed on `localhost:3000` and accessible via default credentials:
```
username: admin
password: admin
```
39 changes: 39 additions & 0 deletions etc/docker-monitoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3'

services:
prometheus:
image: prom/prometheus
ports:
- 9090:9090
volumes:
- ./prometheus/:/etc/prometheus/
- prometheus_data:/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
extra_hosts:
- "host.docker.internal:host-gateway" # https://stackoverflow.com/a/43541732/5204678

grafana:
image: grafana/grafana
ports:
- 3000:3000
environment:
PROMETHEUS_URL: http://prometheus:9090
# 1. Copy dashboards from temp directory to prevent modifying original host files
# 2. Replace Prometheus datasource placeholder with the actual name
# 3. Run Grafana
entrypoint: >
sh -c "cp -r /etc/grafana/provisioning_temp/dashboards/. /etc/grafana/provisioning/dashboards &&
find /etc/grafana/provisioning/dashboards/ -name '*.json' -exec sed -i 's/$${DS_PROMETHEUS}/Prometheus/g' {} \+ &&
/run.sh"
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/datasources:/etc/grafana/provisioning/datasources
- ./grafana/dashboards:/etc/grafana/provisioning_temp/dashboards
depends_on:
- prometheus

volumes:
prometheus_data:
grafana_data:
7 changes: 7 additions & 0 deletions etc/grafana/dashboards/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: 1

providers:
- name: 'Folder'
allowUiUpdates: true
options:
path: /etc/grafana/provisioning/dashboards
File renamed without changes.
8 changes: 8 additions & 0 deletions etc/grafana/datasources/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
access: proxy
url: $PROMETHEUS_URL
editable: true
3 changes: 1 addition & 2 deletions etc/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ scrape_configs:
metrics_path: "/"
scrape_interval: 5s
static_configs:
- targets: ['localhost:9000']

- targets: ['localhost:9000', 'host.docker.internal:9000']

0 comments on commit 4e31c89

Please sign in to comment.