Add prometheus blackbox

certbot_on_virtu
Alexandre Iooss 2019-11-15 14:23:47 +01:00
parent fe7e6c6847
commit 5f5201ddcf
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
13 changed files with 96 additions and 26 deletions
roles
prometheus-apache-exporter
handlers
prometheus-blackbox-exporter
handlers
prometheus-node-exporter
handlers
prometheus-snmp-exporter
handlers
templates/prometheus
prometheus
handlers
templates/prometheus

View File

@ -9,22 +9,31 @@
- targets: [pulsar.adm.crans.org]
prometheus_unifi_snmp_targets:
- targets: "{{ groups['crans_unifi'] | list | sort }}"
prometheus_blackbox_targets:
- targets:
- https://crans.org
- https://www.crans.org
- https://grafana.crans.org
- https://wiki.crans.org
- https://pad.crans.org
prometheus_apache_targets:
- targets: [zamok.adm.crans.org]
snmp_unifi_password: "{{ vault_snmp_unifi_password }}"
roles:
- prometheus
- prometheus-alertmanager
- prometheus-snmp-exporter
- prometheus-blackbox-exporter
# Monitor all hosts
- hosts: server
roles:
- prometheus-node
- prometheus-node-exporter
# Export apache metrics
- hosts: zamok.adm.crans.org
roles:
- prometheus-apache
- prometheus-apache-exporter
# Deploy grafana
- hosts: fy.adm.crans.org

View File

@ -0,0 +1,5 @@
---
- name: Restart prometheus-blackbox-exporter
service:
name: prometheus-blackbox-exporter
state: restarted

View File

@ -0,0 +1,23 @@
---
- name: Install Prometheus Blackbox exporter
apt:
update_cache: true
name: prometheus-blackbox-exporter
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Make Prometheus Blackbox exporter listen on localhost only
lineinfile:
path: /etc/default/prometheus-blackbox-exporter
regexp: '^ARGS='
line: >
ARGS='--config.file /etc/prometheus/blackbox.yml
--web.listen-address=\"localhost:9115\"'"
notify: Restart prometheus-blackbox-exporter
- name: Activate prometheus Blackbox exporter service
systemd:
name: prometheus-blackbox-exporter
enabled: true
state: started

View File

@ -0,0 +1,5 @@
---
- name: Restart prometheus-snmp-exporter
service:
name: prometheus-snmp-exporter
state: restarted

View File

@ -0,0 +1,30 @@
---
- name: Install Prometheus SNMP exporter
apt:
update_cache: true
name: prometheus-snmp-exporter
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Make Prometheus SNMP exporter listen on localhost only
lineinfile:
path: /etc/default/prometheus-snmp-exporter
regexp: '^ARGS='
line: "ARGS=\"--web.listen-address=127.0.0.1:9116\""
notify: Restart prometheus-snmp-exporter
# This file store SNMP OIDs
- name: Configure Prometheus SNMP exporter
template:
src: "prometheus/snmp.yml.j2"
dest: "/etc/prometheus/snmp.yml"
mode: 0600
owner: prometheus
notify: Restart prometheus-snmp-exporter
- name: Activate prometheus SNMP exporter service
systemd:
name: prometheus-snmp-exporter
enabled: true
state: started

View File

@ -3,8 +3,3 @@
service:
name: prometheus
state: restarted
- name: Restart prometheus-snmp-exporter
service:
name: prometheus-snmp-exporter
state: restarted

View File

@ -2,9 +2,7 @@
- name: Install Prometheus
apt:
update_cache: true
name:
- prometheus
- prometheus-snmp-exporter
name: prometheus
register: apt_result
retries: 3
until: apt_result is succeeded
@ -24,22 +22,6 @@
- alert.rules.yml
- django.rules.yml
- name: Make Prometheus snmp-exporter listen on localhost only
lineinfile:
path: /etc/default/prometheus-snmp-exporter
regexp: '^ARGS='
line: "ARGS=\"--web.listen-address=127.0.0.1:9116\""
notify: Restart prometheus-snmp-exporter
# This file store SNMP OIDs
- name: Configure Prometheus snmp-exporter
template:
src: "prometheus/snmp.yml.j2"
dest: "/etc/prometheus/snmp.yml"
mode: 0600
owner: prometheus
notify: Restart prometheus-snmp-exporter
# We don't need to restart Prometheus when updating nodes
- name: Configure Prometheus nodes
copy:
@ -64,6 +46,12 @@
content: "{{ prometheus_apache_targets | to_nice_json }}"
dest: /etc/prometheus/targets_apache.json
# We don't need to restart Prometheus when updating nodes
- name: Configure Prometheus Blackbox targets
copy:
content: "{{ prometheus_blackbox_targets | to_nice_json }}"
dest: /etc/prometheus/targets_blackbox.json
- name: Activate prometheus service
systemd:
name: prometheus

View File

@ -88,6 +88,21 @@ scrape_configs:
target_label: __address__
replacement: '$1:9117'
- job_name: blackbox
file_sd_configs:
- files:
- '/etc/prometheus/targets_blackbox.json'
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9115
- job_name: django
scheme: https
static_configs: