multiple corrections for blackbox exporter

This commit is contained in:
Ludovic Cartier 2021-11-15 18:04:43 +01:00
parent 59550049fc
commit 006ea95681
6 changed files with 20 additions and 16 deletions

View File

@ -31,3 +31,5 @@ prometheus_server_job_name: "prometheus"
prometheus_server_scrape_interval: 5
prometheus_server_scrape_timeout: 5
prometheus_server_version: "latest"
prometheus_blackbox_exporter_host: localhost

View File

@ -27,7 +27,7 @@
- name: 'prometheus | assert | check if docker pyhon libraries are installed'
assert:
that:
- "'python-docker' in ansible_facts.packages"
#- "'python-docker' in ansible_facts.packages"
- "'python3-docker' in ansible_facts.packages"
when:
- prometheus_server_enable is defined

View File

@ -30,8 +30,8 @@
- name: 'prometheus | blackbox exporter | configuration'
template:
src: conf/prometheus-blackbox-exporter.yml.j2
dest: /etc/prometheus/prometheus-blackbox-exporter.yml
src: conf/prometheus-blackbox-exporter.j2
dest: /etc/default/prometheus-blackbox-exporter
owner: root
group: root
mode: 0600
@ -52,3 +52,4 @@
daemon_reload: yes
enabled: yes
name: prometheus-blackbox-exporter.service

View File

@ -160,46 +160,47 @@ scrape_configs:
{% endif %}
{% if prometheus_blackbox_exporter is defined %}
# blacbox #
# blackbox #
{% if prometheus_blackbox_exporter_http is defined %}
{% for target in prometheus_blackbox_exporter_http.values() %}
## http check ##
- job_name: blackbox - url {{ target.service_name }}
- job_name: blackbox - url
scrape_interval: 30s
scrape_timeout: 10s
metrics_path: {{ target.metrics_path }}
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- {{target.host }}
{% for target in prometheus_blackbox_exporter_http %}
- {{target }}
{% endfor %}
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9115
{% endfor %}
replacement: {{ prometheus_blackbox_exporter_host }}:9115
{% endif %}
{% if prometheus_blackbox_exporter_ping is defined %}
{% for target in prometheus_blackbox_exporter_ping.values() %}
## ping ##
- job_name: blackbox - ping {{ target.service_name }}
- job_name: blackbox - ping
scrape_interval: 30s
scrape_timeout: 10s
params:
module: [icmp]
static_configs:
- targets:
- {{ target.host }}
{% for target in prometheus_blackbox_exporter_ping %}
- {{ target }}
{% endfor %}
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9115
{% endfor %}
replacement: {{ prometheus_blackbox_exporter_host }}:9115
{% endif %}
{% endif %}

View File

@ -4,7 +4,7 @@ After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/prometheus-blackbox-exporter --config.file /etc/prometheus/prometheus-blackbox-exporter.yml
ExecStart=/usr/local/bin/prometheus-blackbox-exporter --config.file /etc/default/prometheus-blackbox-exporter
[Install]
WantedBy=multi-user.target