Browse Source

move targets to a dedicated folder

monitoring
histausse 1 year ago
parent
commit
8b6986d955
Signed by: histausse
GPG Key ID: 67486F107F62E9E9
  1. 14
      roles/prometheus-blackbox-exporter/tasks/main.yml
  2. 16
      roles/prometheus/tasks/main.yml
  3. 4
      roles/prometheus/templates/prometheus.yml

14
roles/prometheus-blackbox-exporter/tasks/main.yml

@ -39,20 +39,6 @@
notify: Restart blackbox-exporter
no_log: true
- name: Add targets files
template:
src: targets.json
dest: "/etc/prometheus/blackbox-{{ item }}-targets.json"
owner: prometheus
group: prometheus
mode: '0640'
force: no
notify: Restart blackbox-exporter
loop:
- https-internal
- http-external-up
- http-external-down
#- name: Copy the web-config folder
# template:
# src: web-config.yaml

16
roles/prometheus/tasks/main.yml

@ -18,6 +18,14 @@
owner: prometheus
mode: u=rwx,g=rx,o=rx
- name: Ensure the target folder exist
file:
path: /etc/prometheus/targets
state: directory
group: prometheus
owner: prometheus
mode: u=rwx,g=rx,o=rx
- name: Generate certificate
include_role:
name: generate-cert
@ -51,13 +59,17 @@
- name: Add node targets file
template:
src: node-targets.json
dest: /etc/prometheus/node-targets.json
dest: "/etc/prometheus/targets/{{ item }}-targets.json"
owner: prometheus
group: prometheus
mode: '0640'
force: no
notify: Restart prometheus
no_log: true
loop:
- blackbox-http-external-down
- blackbox-http-external-up
- blackbox-https-internal
- node
- name: Copy the web-config folder
template:

4
roles/prometheus/templates/prometheus.yml

@ -45,7 +45,7 @@ scrape_configs:
- job_name: node
file_sd_configs:
- files:
- '/etc/prometheus/node-targets.json'
- '/etc/prometheus/targets/node-targets.json'
relabel_configs:
# Use hostnames instead of ip for the instance label
- source_labels: [__address__]
@ -71,7 +71,7 @@ scrape_configs:
module: [http_2xx]
file_sd_configs:
- files:
- '/etc/prometheus/blackbox-{{ target_type }}-targets.json'
- '/etc/prometheus/targets/blackbox-{{ target_type }}-targets.json'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target

Loading…
Cancel
Save