Skip to content

Commit

Permalink
Add dockerized metrics local setup (#5173)
Browse files Browse the repository at this point in the history
* Add dockerized metrics local setup

* Review PR
  • Loading branch information
dapplion authored Feb 20, 2023
1 parent 1adb6e1 commit d1cddb7
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ docs/reference/cli.md
*.ssz
.pyrmont
.tmpdb
docker/grafana_dev/dashboards
# EIP-4844 (only commit .ssz file)
packages/beacon-node/trusted_setup.json
packages/beacon-node/trusted_setup.txt
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ docker-compose -f docker-compose.yml -f docker-compose.validator.yml up -d

###### Dockerized metrics + local beacon node:

Run a local beacon with `--metrics` enabled. Then start Prometheus + Grafana with all dashboards in `./dashboards` automatically loaded running:

```
docker-compose -f docker/docker-compose.local.yml up -d
./docker/docker-compose.local_dev.sh
```

## First Time Contributor?
Expand Down
11 changes: 4 additions & 7 deletions docker/docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
version: "3.4"

# Configuration to work with a local non-dockerized Lodestar node
# For local testing and quick debugging
#
# HOW TO USE: Start a Lodestar node, then run
#
# docker-compose -f docker/docker-compose.local.yml up -d
# TODO: How to use?

services:
prometheus:
Expand All @@ -22,7 +17,9 @@ services:
- "prometheus:/prometheus"

grafana:
build: grafana
build:
context: ..
dockerfile: docker/grafana
restart: always
network_mode: host
volumes:
Expand Down
5 changes: 5 additions & 0 deletions docker/docker-compose.local_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

cp -r ./dashboards docker/grafana_dev/dashboards

docker-compose -f docker/docker-compose.local_dev.yml up --build
39 changes: 39 additions & 0 deletions docker/docker-compose.local_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: "3.4"

# Configuration to work with a local non-dockerized Lodestar node
# For local testing and quick debugging
#
# HOW TO USE: Start a Lodestar node, then run
#
# ./docker/docker-compose.local_dev.sh

services:
prometheus:
build:
context: prometheus
environment:
# Linux: http://localhost:8008
# MacOSX: http://host.docker.internal:8008
BEACON_URL: localhost:8008
VC_URL: localhost:5064
restart: always
network_mode: host
volumes:
- "prometheus:/prometheus"

grafana:
build: grafana_dev
restart: always
network_mode: host
volumes:
- "grafana:/var/lib/grafana"
- "grafana-dashboards:/dashboards"
environment:
# Linux: http://localhost:9090
# MacOSX: http://host.docker.internal:9090
PROMETHEUS_URL: http://localhost:9090

volumes:
prometheus:
grafana:
grafana-dashboards:
24 changes: 24 additions & 0 deletions docker/grafana_dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1.4

# Same version as our ansible deployments, to minimize the diff in the dashboard on export
FROM grafana/grafana:8.5.16

# Datasource URL is configured with ENV variables
COPY datasource.yml /etc/grafana/provisioning/datasources/datasource.yml
# Note: Dashboard as linked via a bind volume
COPY dashboard.yml /etc/grafana/provisioning/dashboards/dashboard.yml
# copy over some reasonable default dashboards, user can mount a volume over top of it
COPY dashboards /dashboards/

ENV GF_SECURITY_ADMIN_USER=admin
ENV GF_SECURITY_ADMIN_PASSWORD=admin

# Modified datasource to work with a network_mode: host
ENV PROMETHEUS_URL=http://prometheus:9090
ENV DASHBOARDS_DIR=/dashboards

CMD [ \
"--homepath=/usr/share/grafana", \
"--packaging=docker", \
"cfg:default.paths.data=/var/lib/grafana" \
]
10 changes: 10 additions & 0 deletions docker/grafana_dev/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1

providers:
- name: lodestar_github
type: file
updateIntervalSeconds: 60
allowUiUpdates: true
options:
path: $DASHBOARDS_DIR
foldersFromFilesStructure: true
9 changes: 9 additions & 0 deletions docker/grafana_dev/datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1

datasources:
- name: prometheus
type: prometheus
access: proxy
url: $PROMETHEUS_URL
uid: prometheus
isDefault: true
4 changes: 2 additions & 2 deletions docker/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global:
scrape_interval: 20s
scrape_timeout: 20s
scrape_interval: 5s
scrape_timeout: 5s

# Tags (values starting with #) have to be replaced in the Dockerfile with sed
# Modified datasource to work with a network_mode: host
Expand Down

0 comments on commit d1cddb7

Please sign in to comment.