prometheus: add blackbox exporter
This commit is contained in:
@@ -12,3 +12,5 @@ prometheus_install_webhook: false
|
|||||||
prometheus_install_grafana: false
|
prometheus_install_grafana: false
|
||||||
|
|
||||||
alertmanager_storage_retention: "{{ prometheus_storage_retention }}"
|
alertmanager_storage_retention: "{{ prometheus_storage_retention }}"
|
||||||
|
|
||||||
|
prometheus_ping_hosts: []
|
||||||
|
|||||||
@@ -110,6 +110,13 @@ argument_specs:
|
|||||||
type: str
|
type: str
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
prometheus_ping_hosts:
|
||||||
|
description: List of hosts to gather ping metrics for using prometheus blackbox exporter
|
||||||
|
type: list
|
||||||
|
required: false
|
||||||
|
default: []
|
||||||
|
elements: str
|
||||||
|
|
||||||
# All options after this will be passed directly to the container role
|
# All options after this will be passed directly to the container role
|
||||||
docker_service_suffix:
|
docker_service_suffix:
|
||||||
description: "Passed to container role"
|
description: "Passed to container role"
|
||||||
|
|||||||
@@ -45,6 +45,19 @@
|
|||||||
- name: prometheus
|
- name: prometheus
|
||||||
when: prometheus_install_webhook
|
when: prometheus_install_webhook
|
||||||
|
|
||||||
|
- name: Blackbox exporter for prometheus
|
||||||
|
include_role:
|
||||||
|
name: container
|
||||||
|
vars:
|
||||||
|
docker_service: blackbox_exporter
|
||||||
|
docker_image: prom/blackbox-exporter
|
||||||
|
reverse_proxy_type: none
|
||||||
|
docker_mounts:
|
||||||
|
- template: blackbox_exporter.yml
|
||||||
|
path: /etc/blackbox_exporter/config.yml
|
||||||
|
docker_networks:
|
||||||
|
- name: prometheus
|
||||||
|
|
||||||
- name: Grafana container for prometheus
|
- name: Grafana container for prometheus
|
||||||
include_role:
|
include_role:
|
||||||
name: grafana
|
name: grafana
|
||||||
|
|||||||
8
roles/prometheus/templates/blackbox_exporter.yml.j2
Normal file
8
roles/prometheus/templates/blackbox_exporter.yml.j2
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
modules:
|
||||||
|
icmp:
|
||||||
|
prober: icmp
|
||||||
|
timeout: 5s
|
||||||
|
icmp:
|
||||||
|
preferred_ip_protocol: "ip4"
|
||||||
@@ -26,6 +26,35 @@ scrape_configs:
|
|||||||
static_configs:
|
static_configs:
|
||||||
- targets: ["localhost:9090"]
|
- targets: ["localhost:9090"]
|
||||||
|
|
||||||
|
- job_name: "blackbox"
|
||||||
|
static_configs:
|
||||||
|
- targets: ["blackbox_exporter:9115"]
|
||||||
|
|
||||||
|
{% if prometheus_ping_hosts | length > 0 %}
|
||||||
|
- job_name: "icmp"
|
||||||
|
metrics_path: "/probe"
|
||||||
|
params:
|
||||||
|
module: ["icmp"]
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
{% for host in prometheus_ping_hosts %}
|
||||||
|
- "{{ host.name }}::{{ host.type | default('monitored') }}"
|
||||||
|
{% endfor %}
|
||||||
|
relabel_configs:
|
||||||
|
- source_labels: [__address__]
|
||||||
|
regex: '(.+)::(.+)'
|
||||||
|
target_label: __param_target
|
||||||
|
replacement: '${1}'
|
||||||
|
- source_labels: [__address__]
|
||||||
|
regex: '(.+)::(.+)'
|
||||||
|
target_label: host_type
|
||||||
|
replacement: '${2}'
|
||||||
|
- source_labels: [__param_target]
|
||||||
|
target_label: instance
|
||||||
|
- target_label: __address__
|
||||||
|
replacement: blackbox_exporter:9115
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{% if prometheus_hcloud_enabled %}
|
{% if prometheus_hcloud_enabled %}
|
||||||
- job_name: hcloud
|
- job_name: hcloud
|
||||||
hetzner_sd_configs:
|
hetzner_sd_configs:
|
||||||
|
|||||||
Reference in New Issue
Block a user