Skip to content

Commit

Permalink
Replace evaluate variables in prometheus.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
KaloyanTanev committed Sep 12, 2024
1 parent 9f58444 commit 48c06de
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ cluster-lock.json
.DS_Store
data/
.idea
.charon
.charon
prometheus/prometheus.yml
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,9 @@ services:
user: ":"
networks: [dvnode]
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus:/etc/prometheus
- ./data/prometheus:/prometheus
command:
- "--enable-feature=expand-external-labels"
- "--config.file=/etc/prometheus/prometheus.yml"
entrypoint: /etc/prometheus/run.sh
restart: unless-stopped

grafana:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ global:
scrape_interval: 30s # Set the scrape interval to every 30 seconds.
evaluation_interval: 30s # Evaluate rules every 30 seconds.
external_labels:
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
service_owner: ${SERVICE_OWNER:-charon_user} # replace this with your Operator name you want to be identified by, it helps us route alerts and metrics to your notification channels easily

remote_write:
- url: https://vm.monitoring.gcp.obol.tech/write
authorization:
credentials: $PROM_REMOTE_WRITE_TOKEN
credentials: ${PROM_REMOTE_WRITE_TOKEN}
write_relabel_configs:
- source_labels: [job]
regex: "charon"
Expand Down
17 changes: 17 additions & 0 deletions prometheus/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

if [ -z "$SERVICE_OWNER" ]
then
echo "\$SERVICE_OWNER variable is empty"
fi

if [ -z "$PROM_REMOTE_WRITE_TOKEN" ]
then
echo "\$PROM_REMOTE_WRITE_TOKEN variable is empty"
fi

# eval is used instead of envsubst, as prometheus user doesn't have permissions to install envsubst
eval "echo \"$(cat /etc/prometheus/prometheus.yml.example)\"" > /etc/prometheus/prometheus.yml

/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml

0 comments on commit 48c06de

Please sign in to comment.