Prometheus Apache exporter

certbot_on_virtu
Alexandre Iooss 2019-10-27 21:19:07 +01:00
parent 27e739741a
commit 562372568b
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
5 changed files with 48 additions and 2 deletions

View File

@ -9,6 +9,8 @@
- targets: [pulsar.adm.crans.org] - targets: [pulsar.adm.crans.org]
prometheus_unifi_snmp_targets: prometheus_unifi_snmp_targets:
- targets: "{{ groups['crans_unifi'] | list | sort }}" - targets: "{{ groups['crans_unifi'] | list | sort }}"
prometheus_apache_targets:
- targets: [zamok.adm.crans.org]
roles: roles:
- prometheus - prometheus
- prometheus-alertmanager - prometheus-alertmanager
@ -18,6 +20,11 @@
roles: roles:
- prometheus-node - prometheus-node
# Export apache metrics
- hosts: zamok.adm.crans.org
roles:
- prometheus-apache
# Deploy grafana # Deploy grafana
- hosts: fy.adm.crans.org - hosts: fy.adm.crans.org
vars: vars:

View File

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

View File

@ -0,0 +1,16 @@
---
- name: Install prometheus-apache-exporter
apt:
update_cache: true
name: prometheus-apache-exporter
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Make prometheus-apache-exporter listen on adm only
lineinfile:
path: /etc/default/prometheus-apache-exporter
regexp: '^ARGS='
line: |
ARGS="-telemetry.address={{ ansible_hostname }}.adm.crans.org:9117"
notify: Restart prometheus-apache-exporter

View File

@ -57,6 +57,12 @@
content: "{{ prometheus_unifi_snmp_targets | to_nice_json }}" content: "{{ prometheus_unifi_snmp_targets | to_nice_json }}"
dest: /etc/prometheus/targets_unifi_snmp.json dest: /etc/prometheus/targets_unifi_snmp.json
# We don't need to restart Prometheus when updating nodes
- name: Configure Prometheus Apache targets
copy:
content: "{{ prometheus_apache_targets | to_nice_json }}"
dest: /etc/prometheus/targets_apache.json
- name: Activate prometheus service - name: Activate prometheus service
systemd: systemd:
name: prometheus name: prometheus

View File

@ -76,9 +76,21 @@ scrape_configs:
- target_label: __address__ - target_label: __address__
replacement: 127.0.0.1:9116 replacement: 127.0.0.1:9116
- job_name: apache
file_sd_configs:
- files:
- '/etc/prometheus/targets_apache.json'
relabel_configs:
# Do not put :9117 in instance name, rather here
- source_labels: [__address__]
target_label: instance
- source_labels: [instance]
target_label: __address__
replacement: '$1:9117'
- job_name: django - job_name: django
scheme: https scheme: https
static_configs: static_configs:
# - targets: [] - targets: []
# Activate this line when the captive portal need monitoring # Activate this line when the captive portal need monitoring
- targets: ["portail-captif.crans.org:443"] # - targets: ["portail-captif.crans.org:443"]