Skip to content

Commit 5d02300

Browse files
authored
feat(dashmate): add prometheus service discovery labels (#2818)
1 parent fd2fb2d commit 5d02300

File tree

13 files changed

+197
-18
lines changed

13 files changed

+197
-18
lines changed

packages/dashmate/docker-compose.rate_limiter.metrics.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ services:
1212
image: ${PLATFORM_GATEWAY_RATE_LIMITER_METRICS_DOCKER_IMAGE:?err}
1313
labels:
1414
org.dashmate.service.title: "Gateway rate limiter metrics exporter"
15+
org.dashmate.config.name: "${CONFIG_NAME:?err}"
16+
prometheus.io/scrape: "${PLATFORM_GATEWAY_RATE_LIMITER_METRICS_ENABLED:-false}"
17+
prometheus.io/port: "${PLATFORM_GATEWAY_RATE_LIMITER_METRICS_PORT:?err}"
18+
prometheus.io/path: "/metrics"
1519
restart: unless-stopped
1620
logging: *default-logging
1721
entrypoint: /bin/statsd_exporter

packages/dashmate/docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ services:
5454
image: ${PLATFORM_DRIVE_ABCI_DOCKER_IMAGE:?err}
5555
labels:
5656
org.dashmate.service.title: "Drive ABCI"
57+
org.dashmate.config.name: "${CONFIG_NAME:?err}"
58+
prometheus.io/scrape: "${PLATFORM_DRIVE_ABCI_METRICS_ENABLED:-false}"
59+
prometheus.io/port: "${PLATFORM_DRIVE_ABCI_METRICS_PORT:?err}"
60+
prometheus.io/path: "/metrics"
5761
restart: unless-stopped
5862
logging: *default-logging
5963
volumes:
@@ -111,6 +115,10 @@ services:
111115
image: ${PLATFORM_DRIVE_TENDERDASH_DOCKER_IMAGE:?err}
112116
labels:
113117
org.dashmate.service.title: "Drive Tenderdash"
118+
org.dashmate.config.name: "${CONFIG_NAME:?err}"
119+
prometheus.io/scrape: "${PLATFORM_DRIVE_TENDERDASH_METRICS_ENABLED:-false}"
120+
prometheus.io/port: "${PLATFORM_DRIVE_TENDERDASH_METRICS_PORT:?err}"
121+
prometheus.io/path: "/metrics"
114122
restart: unless-stopped
115123
logging: *default-logging
116124
depends_on:
@@ -132,6 +140,10 @@ services:
132140
image: ${PLATFORM_DAPI_RS_DAPI_DOCKER_IMAGE:?err}
133141
labels:
134142
org.dashmate.service.title: "rs-dapi (Rust DAPI)"
143+
org.dashmate.config.name: "${CONFIG_NAME:?err}"
144+
prometheus.io/scrape: "${PLATFORM_DAPI_RS_DAPI_METRICS_ENABLED:-false}"
145+
prometheus.io/port: "${PLATFORM_DAPI_RS_DAPI_METRICS_PORT:?err}"
146+
prometheus.io/path: "/metrics"
135147
restart: unless-stopped
136148
logging: *default-logging
137149
deploy:
@@ -169,6 +181,10 @@ services:
169181
image: ${PLATFORM_GATEWAY_DOCKER_IMAGE:?err}
170182
labels:
171183
org.dashmate.service.title: "Gateway"
184+
org.dashmate.config.name: "${CONFIG_NAME:?err}"
185+
prometheus.io/scrape: "${PLATFORM_GATEWAY_METRICS_ENABLED:-false}"
186+
prometheus.io/port: "${PLATFORM_GATEWAY_METRICS_PORT:?err}"
187+
prometheus.io/path: "/metrics"
172188
restart: unless-stopped
173189
logging: *default-logging
174190
ports:

packages/dashmate/docs/config/gateway.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ These settings control the metrics endpoint for monitoring the Gateway:
5353
| `platform.gateway.metrics.port` | Port for metrics server | `9090` | `9091` |
5454

5555
Metrics provide performance and health information about the Gateway service.
56-
Admin must be enabled to access the metrics endpoint.
56+
Dashmate automatically enables the Envoy admin endpoint whenever metrics are enabled so that the Prometheus listener can proxy `/stats/prometheus`; if admin itself is still disabled, the listener is not exposed outside of Docker.
5757

5858
## Admin
5959

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Prometheus Configuration
2+
3+
This directory contains a minimal Prometheus stack for scraping metrics from a Dashmate-managed Platform network. It is meant for local debugging and pairs with the metric endpoints that Dashmate exposes when you enable them in your node configuration.
4+
5+
## Files
6+
- `docs/prometheus/docker-compose.yml` brings up two containers: a read-only Docker Socket Proxy that exposes `tcp://127.0.0.1:2375`, and Prometheus itself listening on `:9080`.
7+
- `docs/prometheus/prometheus.yml` configures Prometheus to use Docker service discovery against the proxy and scrape every container that carries Dashmate’s `prometheus.io/*` labels.
8+
9+
## Prepare Dashmate
10+
1. Enable metrics on the services you want Prometheus to monitor (examples):
11+
- `dashmate config set platform.drive.abci.metrics.enabled true`
12+
- `dashmate config set platform.drive.tenderdash.metrics.enabled true`
13+
- `dashmate config set platform.dapi.rsDapi.metrics.enabled true`
14+
- `dashmate config set platform.gateway.metrics.enabled true`
15+
- `dashmate config set platform.gateway.rateLimiter.metrics.enabled true`
16+
2. Restart your network so the containers are recreated with the Prometheus labels: `yarn restart`.
17+
18+
The labels Dashmate adds map cleanly onto the Prometheus discovery config:
19+
- `prometheus.io/scrape=true` enables scraping.
20+
- `prometheus.io/path` overrides the metrics path (defaults to `/metrics`).
21+
- `prometheus.io/port` is rewritten to `127.0.0.1:<port>` so scraping stays on the host network.
22+
- `org_dashmate_service_title` and `org_dashmate_config_name` become `service` and `config` labels on each time series.
23+
24+
## Run Prometheus
25+
```bash
26+
docker compose -f docs/prometheus/docker-compose.yml up -d
27+
```
28+
29+
Prometheus stores data in the `prometheus-data` volume and exposes its UI at `http://127.0.0.1:9080`. Reload the configuration after any edits with:
30+
```bash
31+
curl -X POST http://127.0.0.1:9080/-/reload
32+
```
33+
34+
### Customisation Tips
35+
- Adjust `scrape_interval` or add more `scrape_configs` in `prometheus.yml` as needed.
36+
- To scrape additional containers, attach the same `prometheus.io/*` labels to them, or add dedicated jobs to the configuration.
37+
- If your Docker daemon is not local, update the proxy service or mount a different socket before starting the stack.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
3+
services:
4+
docker_socket_proxy:
5+
image: tecnativa/docker-socket-proxy:latest
6+
container_name: prometheus-docker-socket-proxy
7+
restart: unless-stopped
8+
environment:
9+
- CONTAINERS=1
10+
- NETWORKS=1
11+
volumes:
12+
- /var/run/docker.sock:/var/run/docker.sock:ro
13+
ports:
14+
- "127.0.0.1:2375:2375"
15+
16+
prometheus:
17+
image: prom/prometheus:latest
18+
container_name: prometheus-rsdapi
19+
network_mode: host
20+
depends_on:
21+
- docker_socket_proxy
22+
command:
23+
- --config.file=/etc/prometheus/prometheus.yml
24+
- --storage.tsdb.path=/prometheus
25+
- --web.enable-lifecycle
26+
- --web.listen-address=:9080
27+
volumes:
28+
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
29+
- prometheus-data:/prometheus
30+
restart: unless-stopped
31+
32+
volumes:
33+
prometheus-data:
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
3+
global:
4+
scrape_interval: 15s
5+
scrape_timeout: 10s
6+
7+
scrape_configs:
8+
- job_name: dashmate
9+
metrics_path: /metrics
10+
docker_sd_configs:
11+
- host: tcp://127.0.0.1:2375
12+
refresh_interval: 15s
13+
relabel_configs:
14+
- source_labels: [__meta_docker_container_label_prometheus_io_scrape]
15+
action: keep
16+
regex: true
17+
- source_labels: [__meta_docker_container_label_prometheus_io_path]
18+
target_label: __metrics_path__
19+
regex: (.+)
20+
- source_labels: [__meta_docker_container_label_prometheus_io_port]
21+
action: replace
22+
regex: (.+)
23+
replacement: 127.0.0.1:$1
24+
target_label: __address__
25+
- source_labels: [__meta_docker_container_label_org_dashmate_service_title]
26+
target_label: service
27+
regex: (.+)
28+
- source_labels: [__meta_docker_container_label_org_dashmate_config_name]
29+
target_label: config
30+
regex: (.+)

packages/dashmate/docs/services/gateway.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Metrics include:
260260
- Host: `platform.gateway.metrics.host` (default: 127.0.0.1)
261261
- Port: `platform.gateway.metrics.port` (default: 9090)
262262

263-
**Note:** admin interface must be enabled too.
263+
**Note:** Dashmate automatically enables the Envoy admin endpoint whenever metrics are turned on so the Prometheus listener can proxy `/stats/prometheus`. If the admin service remains disabled, this socket is not exposed outside Docker; once you explicitly enable admin, it uses the host you configure.
264264

265265
### Security Considerations
266266

packages/dashmate/docs/services/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,6 @@ Most services provide metrics endpoints:
119119
- Rate Limiter: Rate limiting metrics
120120

121121
These can be integrated with monitoring systems like Prometheus and Grafana.
122+
All containers that expose Prometheus metrics also advertise the Docker label `org.dashmate.config.name`, which Dashmate sets to the active config name. When you run multiple nodes on the same host, you can use that label in Prometheus relabeling rules or dashboards to distinguish each instance.
123+
124+
You can find example Prometheus config for local devnet monitoring in [../prometheus/](../prometheus/README.md).

packages/dashmate/src/doctor/analyse/analyseConfigFactory.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,6 @@ export default function analyseConfigFactory() {
1616
const problems = [];
1717

1818
if (config?.get('platform.enable')) {
19-
// Gateway admin is disabled while metrics are enabled
20-
if (config.get('platform.gateway.metrics.enabled') && !config.get('platform.gateway.admin.enabled')) {
21-
const problem = new Problem(
22-
'Gateway admin is disabled while metrics are enabled',
23-
chalk`Please enable gateway admin: {bold.cyanBright dashmate config set platform.gateway.admin.enabled true}`,
24-
SEVERITY.HIGH,
25-
);
26-
27-
problems.push(problem);
28-
}
29-
3019
// Platform Node ID
3120
const masternodeStatus = samples.getServiceInfo('core', 'masternodeStatus');
3221
const platformNodeId = masternodeStatus?.dmnState?.platformNodeId;

packages/dashmate/templates/dynamic-compose.yml.dot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ services:
3939
{{? it.platform.dapi.rsDapi.metrics.enabled }}
4040
ports:
4141
- {{=it.platform.dapi.rsDapi.metrics.host}}:{{=it.platform.dapi.rsDapi.metrics.port}}:{{=it.platform.dapi.rsDapi.metrics.port}}
42-
{{??}}
43-
ports: []
4442
{{?}}
4543
{{?}}
4644

0 commit comments

Comments
 (0)