From 57738cc725b07437995db87393970b02a7fe7257 Mon Sep 17 00:00:00 2001 From: pz2891 Date: Wed, 8 Sep 2021 12:06:56 +0200 Subject: [PATCH] Prometheus scrape ipmi collectors --- monitoring.yml | 3 +++ roles/prometheus/tasks/main.yml | 7 +++++++ roles/prometheus/templates/prometheus.yml.j2 | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/monitoring.yml b/monitoring.yml index 0f5113a..24b3ad7 100755 --- a/monitoring.yml +++ b/monitoring.yml @@ -54,6 +54,9 @@ prometheus_targets: - targets: | {{ groups['edc_pve'] + groups['edc_vm'] + groups['edc_server'] | list | sort }} + prometheus_ipmi_targets: + - targets: | + {{ groups['edc_pve'] + groups['edc_server'] | list | sort }} prometheus_unifi_snmp_targets: - targets: "{{ groups['edc_unifi'] | list | sort }}" roles: diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml index f9e48e8..92df23a 100644 --- a/roles/prometheus/tasks/main.yml +++ b/roles/prometheus/tasks/main.yml @@ -113,6 +113,13 @@ mode: 0644 when: prometheus_pdu_snmp_targets is defined +- name: Configure Prometheus ipmi targets monitoring + copy: + content: "{{ prometheus_ipmi_targets | to_nice_json }}\n" + dest: /etc/prometheus/targets_ipmi.json + mode: 0644 + when: prometheus_ipmi_targets is defined + - name: Activate prometheus service systemd: name: prometheus diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 index 4400de3..2402ae6 100644 --- a/roles/prometheus/templates/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -140,4 +140,22 @@ scrape_configs: - target_label: __address__ replacement: 127.0.0.1:9116 + - job_name: ipmi + file_sd_configs: + - files: + - '/etc/prometheus/targets_ipmi.json' + metrics_path: /metrics + params: + module: [default] + relabel_configs: + # Do not put :9290 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:9290' + + ...