From 46e2111368c8164cffb58bc8697b7c0c8bd90b5b Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sun, 13 Oct 2019 10:43:45 +0200 Subject: [PATCH] [prometheus] Do not put :9100 in instance name --- monitoring.yml | 7 +------ .../templates/prometheus/prometheus.yml.j2 | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/monitoring.yml b/monitoring.yml index 1b6f9d10..1ab0f417 100644 --- a/monitoring.yml +++ b/monitoring.yml @@ -4,12 +4,7 @@ vars: # Prometheus targets.json prometheus_targets: - - labels: {job: node} - targets: | - {{ groups['server'] | map('replace', '.org', '.org:9100') | - list | sort }} - - labels: {job: prometheus} - targets: ['localhost:9090'] + - targets: "{{ groups['server'] | list | sort }}" prometheus_ups_snmp_targets: - targets: [pulsar.adm.crans.org] prometheus_unifi_snmp_targets: diff --git a/roles/prometheus/templates/prometheus/prometheus.yml.j2 b/roles/prometheus/templates/prometheus/prometheus.yml.j2 index 39f3c5ff..57397c87 100644 --- a/roles/prometheus/templates/prometheus/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus/prometheus.yml.j2 @@ -27,10 +27,24 @@ rule_files: scrape_configs: # The .json in file_sd_configs is dynamically reloaded - - job_name: dummy + - job_name: prometheus + static_configs: + - targets: + - localhost:9090 + + - job_name: servers file_sd_configs: - files: - '/etc/prometheus/targets.json' + relabel_configs: + # Do not put :9100 in instance name, rather here + - source_labels: [__address__] + target_label: __param_target + - source_labels: [__param_target] + target_label: instance + - source_labels: [__param_target] + target_label: __address__ + replacement: '$1:9100' - job_name: ups_snmp file_sd_configs: