diff --git a/packer/prometheus.service b/packer/prometheus.service index 043c45b..aa588ce 100644 --- a/packer/prometheus.service +++ b/packer/prometheus.service @@ -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 diff --git a/packer/prometheus.yaml b/packer/prometheus.yaml index fbc2550..c883fca 100644 --- a/packer/prometheus.yaml +++ b/packer/prometheus.yaml @@ -1,5 +1,7 @@ global: scrape_interval: 15s + external_labels: + node: "${EC2_INSTANCE_ID}" scrape_configs: - job_name: server diff --git a/packer/promtail.service b/packer/promtail.service index eabf709..36eba70 100644 --- a/packer/promtail.service +++ b/packer/promtail.service @@ -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