Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/.DS_Store
grafana/grafana-data
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ You should now have three containers.
|--------------------|------------|---------------------------|
| Bitcoin Node | 8332, 8333 | Bitcoin RPC and P2P ports |
| NATS | 4222 | Message broker |
| Metrics | 8282 | Metrics HTTP endpoint |
| Metrics | 8001 | Metrics HTTP endpoint |
| WebSocket | 47482 | Real-time data WebSocket |
| Connectivity Check | 18282 | Connectivity metrics |
| Prometheus | 9090 | Datasource for Grafana |
| Grafana | 3000 | Data visualization |

## Usage

Expand All @@ -99,9 +101,11 @@ docker compose logs -f bitcoin-node

Once all services are running:

- **Metrics**: `http://localhost:8282`
- **Metrics**: `http://localhost:8001`
- **Connectivity Metrics**: `http://localhost:18282`
- **WebSocket Connection**: `ws://localhost:47482`
- **Prometheus**: `http://localhost:9090`
- **Grafana**: `http://localhost:3000`, username: `admin`, password: `admin`

### Stopping Services

Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ include:
- docker-compose/node.override.regtest.yml
- path: docker-compose/logger.yml
- path: docker-compose/connectivity-check.yml
- path: docker-compose/metrics.yml
- path: docker-compose/websocket.yml
- path: docker-compose/metrics.yml
- path: docker-compose/prometheus.yml
- path: docker-compose/grafana.yml
16 changes: 16 additions & 0 deletions docker-compose/grafana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
grafana:
build:
context: ..
dockerfile: docker/grafana.dockerfile
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
depends_on:
- prometheus
profiles: [monitoring, metrics]

volumes:
grafana-data:
4 changes: 2 additions & 2 deletions docker-compose/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ services:
context: ../
dockerfile: docker/peer-observer-tools.dockerfile
command:
["/home/appuser/metrics", "--nats-address", "nats://nats:4222", "--metrics-address", "0.0.0.0:8282"]
["/home/appuser/metrics", "--nats-address", "nats://nats:4222", "--metrics-address", "0.0.0.0:8001"]
ports:
- "8282:8282"
- "8001:8001"
depends_on:
nats:
condition: service_healthy
Expand Down
1 change: 1 addition & 0 deletions docker-compose/nats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
dockerfile: docker/nats.dockerfile
ports:
- "4222:4222"
- "8222:8222"
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8222/healthz"]
interval: 1m
Expand Down
12 changes: 12 additions & 0 deletions docker-compose/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
prometheus:
image: prom/prometheus:latest
volumes:
- ../prometheus/prometheus-config.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
ports:
- "9090:9090"
depends_on:
- metrics
profiles: [monitoring, metrics]
21 changes: 21 additions & 0 deletions docker/grafana.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM grafana/grafana:latest

# Optional argument for deterministic builds
ARG PEER_EXTRACTOR_REPO=https://github.com/0xB10C/peer-observer.git
ARG PEER_EXTRACTOR_BRANCH=master
ARG PEER_EXTRACTOR_COMMIT=87823b767c74e60b23c9a150984c7001d245277b

USER root
RUN apk add --no-cache git

# Clone only the needed commit and extract dashboards
RUN git clone -b $PEER_EXTRACTOR_BRANCH --single-branch $PEER_EXTRACTOR_REPO /tmp/peer-observer \
&& cd /tmp/peer-observer \
&& git checkout $PEER_OBSERVER_COMMIT \
&& mkdir -p /etc/grafana/dashboards \
&& cp -r tools/metrics/dashboards/playlist/*.json /etc/grafana/dashboards/ \
&& rm -rf /tmp/peer-observer

COPY grafana/provisioning /etc/grafana/provisioning

USER grafana
11 changes: 11 additions & 0 deletions grafana/provisioning/dashboards/dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1

providers:
- name: 'peer-observer'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/dashboards
9 changes: 9 additions & 0 deletions grafana/provisioning/datasources/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: http://prometheus:9090
uid: P1809F7CD0C75ACF3
isDefault: true
9 changes: 9 additions & 0 deletions prometheus/prometheus-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global:
scrape_interval: 15s

scrape_configs:
- job_name: 'metrics'
static_configs:
- targets: ['metrics:8001']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To allow for a multi-node setup, I use the label host in my set up for the dashboards. Even if you just have one host, you probably want to add a name for it here. See also https://github.com/0xB10C/peer-observer/tree/master/tools/metrics#grafana-dashboards

Suggested change
- targets: ['metrics:8001']
- targets: ['metrics:8001']
labels:
host: node1

labels:
host: bitcoin-node