Skip to content

Commit 7161421

Browse files
authored
feat: add cluster_name and cluster_peer labels to Prometheus metrics (#436)
## Summary - Add `cluster_name` and `cluster_peer` as `external_labels` in Prometheus config - These labels are already used by Alloy for logs but were missing from metrics sent via `remote_write` - Pass `CLUSTER_NAME` and `CLUSTER_PEER` env vars to the Prometheus container in docker-compose - Render the new variables in `run.sh` via `sed` (same pattern as existing vars) ## Changes - `prometheus/prometheus.yml.example` — add `cluster_name` and `cluster_peer` external labels - `prometheus/run.sh` — render `$CLUSTER_NAME` and `$CLUSTER_PEER` via sed - `docker-compose.yml` — pass `CLUSTER_NAME` and `CLUSTER_PEER` env vars to prometheus service
1 parent 2246970 commit 7161421

3 files changed

Lines changed: 6 additions & 0 deletions

File tree

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ services:
177177
environment:
178178
PROM_REMOTE_WRITE_TOKEN: ${PROM_REMOTE_WRITE_TOKEN}
179179
SERVICE_OWNER: ${SERVICE_OWNER:-"obol-cdvn"}
180+
CLUSTER_NAME: ${CLUSTER_NAME:-}
181+
CLUSTER_PEER: ${CLUSTER_PEER:-}
180182
volumes:
181183
- ./prometheus:/etc/prometheus
182184
- ./data/prometheus:/prometheus

prometheus/prometheus.yml.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ global:
33
evaluation_interval: 30s # Evaluate rules every 30 seconds.
44
external_labels:
55
service_owner: $SERVICE_OWNER # replace this with your Operator name you want to be identified by, it helps us route alerts and metrics to your notification channels easily
6+
cluster_name: $CLUSTER_NAME
7+
cluster_peer: $CLUSTER_PEER
68

79
remote_write:
810
- url: https://vm.monitoring.gcp.obol.tech/write

prometheus/run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ fi
1414

1515
sed -e "s|\$PROM_REMOTE_WRITE_TOKEN|${PROM_REMOTE_WRITE_TOKEN}|g" \
1616
-e "s|\$SERVICE_OWNER|${SERVICE_OWNER}|g" \
17+
-e "s|\$CLUSTER_NAME|${CLUSTER_NAME}|g" \
18+
-e "s|\$CLUSTER_PEER|${CLUSTER_PEER}|g" \
1719
-e "s|\$ALERT_DISCORD_IDS|${ALERT_DISCORD_IDS}|g" \
1820
/etc/prometheus/prometheus.yml.example > /etc/prometheus/prometheus.yml
1921

0 commit comments

Comments
 (0)