Add dockerized metrics local setup (#5173)

* Add dockerized metrics local setup

* Review PR
This commit is contained in:
Lion - dapplion
2023-02-21 00:08:46 +08:00
committed by GitHub
parent 1adb6e1452
commit d1cddb7ca8
9 changed files with 97 additions and 10 deletions

1
.gitignore vendored
View File

@@ -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

View File

@@ -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?

View File

@@ -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:
@@ -22,7 +17,9 @@ services:
- "prometheus:/prometheus"
grafana:
build: grafana
build:
context: ..
dockerfile: docker/grafana
restart: always
network_mode: host
volumes:

View File

@@ -0,0 +1,5 @@
#!/bin/bash
cp -r ./dashboards docker/grafana_dev/dashboards
docker-compose -f docker/docker-compose.local_dev.yml up --build

View File

@@ -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:

View File

@@ -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" \
]

View File

@@ -0,0 +1,10 @@
apiVersion: 1
providers:
- name: lodestar_github
type: file
updateIntervalSeconds: 60
allowUiUpdates: true
options:
path: $DASHBOARDS_DIR
foldersFromFilesStructure: true

View File

@@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- name: prometheus
type: prometheus
access: proxy
url: $PROMETHEUS_URL
uid: prometheus
isDefault: true

View File

@@ -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