move targets to a dedicated folder

monitoring
histausse 3 years ago
parent a28064ca9b
commit 8b6986d955
Signed by: histausse
GPG Key ID: 67486F107F62E9E9

@ -39,20 +39,6 @@
notify: Restart blackbox-exporter notify: Restart blackbox-exporter
no_log: true 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 #- name: Copy the web-config folder
# template: # template:
# src: web-config.yaml # src: web-config.yaml

@ -18,6 +18,14 @@
owner: prometheus owner: prometheus
mode: u=rwx,g=rx,o=rx 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 - name: Generate certificate
include_role: include_role:
name: generate-cert name: generate-cert
@ -51,13 +59,17 @@
- name: Add node targets file - name: Add node targets file
template: template:
src: node-targets.json src: node-targets.json
dest: /etc/prometheus/node-targets.json dest: "/etc/prometheus/targets/{{ item }}-targets.json"
owner: prometheus owner: prometheus
group: prometheus group: prometheus
mode: '0640' mode: '0640'
force: no force: no
notify: Restart prometheus 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 - name: Copy the web-config folder
template: template:

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

Loading…
Cancel
Save