first implement of blackbox
This commit is contained in:
parent
6e060e5ab0
commit
2214426937
@ -53,3 +53,10 @@
|
|||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
tags: ['prometheus']
|
tags: ['prometheus']
|
||||||
|
|
||||||
|
- name: 'prometheus | blackbox exporter | restart service'
|
||||||
|
systemd:
|
||||||
|
name: prometheus-blackbox-exporter.service
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
tags: ['prometheus']
|
||||||
|
56
tasks/blackbox.yml
Normal file
56
tasks/blackbox.yml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
---
|
||||||
|
- name: 'prometheus | blackbox exporter | get latest release from GitHub'
|
||||||
|
shell: curl --silent "https://api.github.com/repos/prometheus/blackbox_exporter/releases/latest" | jq -r .tag_name | sed "s/v//"
|
||||||
|
args:
|
||||||
|
warn: false
|
||||||
|
register: prometheus_blackbox_exporter_latest_version
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
- name: 'prometheus | blackbox exporter | download'
|
||||||
|
get_url:
|
||||||
|
url: https://github.com/prometheus/blackbox_exporter/releases/download/v{{ prometheus_blackbox_exporter_version|default(prometheus_blackbox_exporter_latest_version.stdout) }}/blackbox_exporter-{{ prometheus_blackbox_exporter_version|default(prometheus_blackbox_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
||||||
|
dest: /tmp
|
||||||
|
|
||||||
|
- name: 'prometheus | blackbox exporter | unarchive'
|
||||||
|
unarchive:
|
||||||
|
remote_src: yes
|
||||||
|
src: /tmp/blackbox_exporter-{{ prometheus_blackbox_exporter_version|default(prometheus_blackbox_exporter_latest_version.stdout) }}.linux-amd64.tar.gz
|
||||||
|
dest: /tmp
|
||||||
|
|
||||||
|
- name: 'prometheus | blackbox exporter | move to /usr/local/bin'
|
||||||
|
copy:
|
||||||
|
src: /tmp/blackbox_exporter-{{ prometheus_blackbox_exporter_version|default(prometheus_blackbox_exporter_latest_version.stdout) }}.linux-amd64/blackbox_exporter
|
||||||
|
dest: /usr/local/bin/prometheus-blackbox-exporter
|
||||||
|
remote_src: yes
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
notify:
|
||||||
|
- 'prometheus | blackbox exporter | restart service'
|
||||||
|
|
||||||
|
- name: 'prometheus | blackbox exporter | configuration'
|
||||||
|
template:
|
||||||
|
src: conf/prometheus-blackbox-exporter.j2
|
||||||
|
dest: /etc/prometheus/prometheus-blackbox-exporter.yml
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0600
|
||||||
|
when:
|
||||||
|
- prometheus_blackbox_exporter_user is defined
|
||||||
|
register: prometheus_blackbox_exporter_configuration
|
||||||
|
notify:
|
||||||
|
- 'prometheus | blackbox exporter | restart service'
|
||||||
|
|
||||||
|
- name: 'prometheus | blackbox exporter | install unit file to systemd'
|
||||||
|
template:
|
||||||
|
src: systemd/prometheus-blackbox-exporter.service.j2
|
||||||
|
dest: /etc/systemd/system/prometheus-blackbox-exporter.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0600
|
||||||
|
|
||||||
|
- name: 'prometheus | blackbox exporter | configure systemd to use service'
|
||||||
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
enabled: yes
|
||||||
|
name: prometheus-blackbox-exporter.service
|
@ -44,3 +44,8 @@
|
|||||||
include_tasks: 'varnish_exporter.yml'
|
include_tasks: 'varnish_exporter.yml'
|
||||||
when:
|
when:
|
||||||
- "'varnish' in prometheus_exporter_packages"
|
- "'varnish' in prometheus_exporter_packages"
|
||||||
|
|
||||||
|
- name: 'prometheus | Blackbox exporter'
|
||||||
|
include_tasks: 'varnish_exporter.yml'
|
||||||
|
when:
|
||||||
|
- "'blackbox' in prometheus_exporter_packages"
|
||||||
|
37
templates/conf/prometheus-blackbox-exporter.yml.j2
Normal file
37
templates/conf/prometheus-blackbox-exporter.yml.j2
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
modules:
|
||||||
|
http_2xx:
|
||||||
|
prober: http
|
||||||
|
timeout: 30s
|
||||||
|
http:
|
||||||
|
preferred_ip_protocol: "ipv4"
|
||||||
|
http_post_2xx:
|
||||||
|
prober: http
|
||||||
|
http:
|
||||||
|
preferred_ip_protocol: "ipv4"
|
||||||
|
method: POST
|
||||||
|
tcp_connect:
|
||||||
|
prober: tcp
|
||||||
|
pop3s_banner:
|
||||||
|
prober: tcp
|
||||||
|
tcp:
|
||||||
|
query_response:
|
||||||
|
- expect: "^+OK"
|
||||||
|
tls: true
|
||||||
|
tls_config:
|
||||||
|
insecure_skip_verify: false
|
||||||
|
ssh_banner:
|
||||||
|
prober: tcp
|
||||||
|
tcp:
|
||||||
|
query_response:
|
||||||
|
- expect: "^SSH-2.0-"
|
||||||
|
irc_banner:
|
||||||
|
prober: tcp
|
||||||
|
tcp:
|
||||||
|
query_response:
|
||||||
|
- send: "NICK prober"
|
||||||
|
- send: "USER prober prober prober :prober"
|
||||||
|
- expect: "PING :([^ ]+)"
|
||||||
|
send: "PONG ${1}"
|
||||||
|
- expect: "^:[^ ]+ 001"
|
||||||
|
icmp:
|
||||||
|
prober: icmp
|
@ -32,6 +32,7 @@ scrape_configs:
|
|||||||
- targets: ['localhost:9090']
|
- targets: ['localhost:9090']
|
||||||
|
|
||||||
{% if prometheus_node_exporter_targets is defined %}
|
{% if prometheus_node_exporter_targets is defined %}
|
||||||
|
# node exporter #
|
||||||
- job_name: node
|
- job_name: node
|
||||||
scrape_interval: 30s
|
scrape_interval: 30s
|
||||||
scrape_timeout: 10s
|
scrape_timeout: 10s
|
||||||
@ -43,6 +44,7 @@ scrape_configs:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if prometheus_mysqld_exporter_targets is defined %}
|
{% if prometheus_mysqld_exporter_targets is defined %}
|
||||||
|
# mysql exporter #
|
||||||
- job_name: mysql
|
- job_name: mysql
|
||||||
scrape_interval: 30s
|
scrape_interval: 30s
|
||||||
scrape_timeout: 10s
|
scrape_timeout: 10s
|
||||||
@ -65,6 +67,7 @@ scrape_configs:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if prometheus_mongodb_exporter_targets is defined %}
|
{% if prometheus_mongodb_exporter_targets is defined %}
|
||||||
|
# mongoDB exporter #
|
||||||
- job_name: mongodb
|
- job_name: mongodb
|
||||||
scrape_interval: 30s
|
scrape_interval: 30s
|
||||||
scrape_timeout: 10s
|
scrape_timeout: 10s
|
||||||
@ -87,6 +90,7 @@ scrape_configs:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if prometheus_postgres_exporter_targets is defined %}
|
{% if prometheus_postgres_exporter_targets is defined %}
|
||||||
|
# postgresql exporter #
|
||||||
- job_name: postgresql
|
- job_name: postgresql
|
||||||
scrape_interval: 30s
|
scrape_interval: 30s
|
||||||
scrape_timeout: 10s
|
scrape_timeout: 10s
|
||||||
@ -109,6 +113,7 @@ scrape_configs:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if prometheus_phpfpm_exporter_targets is defined %}
|
{% if prometheus_phpfpm_exporter_targets is defined %}
|
||||||
|
# PHP-FPM exporter #
|
||||||
- job_name: phpfpm
|
- job_name: phpfpm
|
||||||
scrape_interval: 30s
|
scrape_interval: 30s
|
||||||
scrape_timeout: 10s
|
scrape_timeout: 10s
|
||||||
@ -120,6 +125,7 @@ scrape_configs:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if prometheus_apache_exporter_targets is defined %}
|
{% if prometheus_apache_exporter_targets is defined %}
|
||||||
|
# apache exporter #
|
||||||
- job_name: apache
|
- job_name: apache
|
||||||
scrape_interval: 30s
|
scrape_interval: 30s
|
||||||
scrape_timeout: 10s
|
scrape_timeout: 10s
|
||||||
@ -131,6 +137,7 @@ scrape_configs:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if prometheus_haproxy_exporter_targets is defined %}
|
{% if prometheus_haproxy_exporter_targets is defined %}
|
||||||
|
# haproxy exporter #
|
||||||
- job_name: haproxy
|
- job_name: haproxy
|
||||||
scrape_interval: 30s
|
scrape_interval: 30s
|
||||||
scrape_timeout: 10s
|
scrape_timeout: 10s
|
||||||
@ -151,3 +158,45 @@ scrape_configs:
|
|||||||
- {{ target }}:9131
|
- {{ target }}:9131
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
//
|
||||||
|
{% if prometheus_blackbox_exporter_targets is defined %}
|
||||||
|
# blacbox #
|
||||||
|
{% for target in prometheus_blackbox_exporter_http.values() %}
|
||||||
|
## http check ##
|
||||||
|
- job_name: blackbox - url {{ target.name }}
|
||||||
|
scrape_interval: 30s
|
||||||
|
scrape_timeout: 10s
|
||||||
|
metrics_path: {{ target.metrics_path }}
|
||||||
|
params:
|
||||||
|
module: [http_2xx]
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
- {{target.host }}
|
||||||
|
relabel_configs:
|
||||||
|
- source_labels: [__address__]
|
||||||
|
target_label: __param_target
|
||||||
|
- source_labels: [__param_target]
|
||||||
|
target_label: instance
|
||||||
|
- target_label: __address__
|
||||||
|
replacement: localhost:9115
|
||||||
|
{% endfor %}
|
||||||
|
{% for target in prometheus_blackbox_exporter_ping.values() %}
|
||||||
|
## ping ##
|
||||||
|
- job_name: blackbox - ping {{ target.name }}
|
||||||
|
scrape_interval: 30s
|
||||||
|
scrape_timeout: 10s
|
||||||
|
params:
|
||||||
|
module: [icmp]
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
- {{ target.host }}
|
||||||
|
relabel_configs:
|
||||||
|
- source_labels: [__address__]
|
||||||
|
target_label: __param_target
|
||||||
|
- source_labels: [__param_target]
|
||||||
|
target_label: instance
|
||||||
|
- target_label: __address__
|
||||||
|
replacement: localhost:9115
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
10
templates/systemd/prometheus-blackbox-exporter.service.j2
Normal file
10
templates/systemd/prometheus-blackbox-exporter.service.j2
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Prometheus Blacbox Exporter
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/local/bin/prometheus-blackbox-exporter --config.file /etc/prometheus/prometheus-blackbox-exporter.yml
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
x
Reference in New Issue
Block a user