Set external-labels correctly for Prometheus

This commit is contained in:
Radon Rosborough 2022-02-11 21:44:48 -08:00
parent 9e80286cbe
commit d761cd7dff
3 changed files with 4 additions and 2 deletions

View File

@ -5,7 +5,7 @@ StartLimitIntervalSec=300
[Service]
Type=exec
ExecStart=prometheus --config.file /etc/prometheus/config.yaml
ExecStart=bash -c 'EC2_INSTANCE_ID="$(curl -fsSL http://169.254.169.254/latest/meta-data/instance-id)" prometheus --config.file /etc/prometheus/config.yaml --enable-feature=expand-external-labels'
Restart=always
RestartSec=5

View File

@ -1,5 +1,7 @@
global:
scrape_interval: 15s
external_labels:
node: "${EC2_INSTANCE_ID}"
scrape_configs:
- job_name: server

View File

@ -5,7 +5,7 @@ StartLimitIntervalSec=300
[Service]
Type=exec
ExecStart=bash -c 'promtail -config.file /etc/promtail/config.yaml -client.external-labels instance="$(curl -fsSL http://169.254.169.254/latest/meta-data/instance-id)"'
ExecStart=bash -c 'promtail -config.file /etc/promtail/config.yaml -client.external-labels node="$(curl -fsSL http://169.254.169.254/latest/meta-data/instance-id)"'
Restart=always
RestartSec=5