From 1f3e76e4f6f99ca134fc1eadd9ddb02343b82b9d Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sat, 17 Feb 2024 17:59:16 +0000 Subject: [PATCH] Enable mysqld_exporter for prometheus hosts --- hosts.yml | 2 ++ playbooks/prometheus.yml | 1 + roles/prometheus/templates/prometheus.yml.j2 | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/hosts.yml b/hosts.yml index 8fb7bd0..7e8fc7c 100644 --- a/hosts.yml +++ b/hosts.yml @@ -96,6 +96,8 @@ print: prometheus: hosts: prometheus02.home.foo.sh: + vars: + mysqld_exporter_version: "0.15.1" proxy: hosts: proxy01.home.foo.sh: diff --git a/playbooks/prometheus.yml b/playbooks/prometheus.yml index bec40ff..856b0a3 100644 --- a/playbooks/prometheus.yml +++ b/playbooks/prometheus.yml @@ -26,3 +26,4 @@ roles: - base - prometheus + - mysqld_exporter diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 index e4a4956..49520f9 100644 --- a/roles/prometheus/templates/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -10,6 +10,25 @@ scrape_configs: - targets: - "127.0.0.1:9090" + - job_name: mysqld + scheme: https + tls_config: + ca_file: "{{ tls_certs }}/ca.crt" + key_file: "{{ tls_private }}/{{ inventory_hostname }}.key" + cert_file: "{{ tls_certs }}/{{ inventory_hostname }}.crt" + static_configs: + - targets: +{% for host in groups['sqldb'] %} + - {{ host }}:3306 +{% endfor %} + relabel_configs: + - source_labels: [__address__] + target_label: __param_target + - source_labels: [__param_target] + target_label: instance + - target_label: __address__ + replacement: {{ inventory_hostname }}:9104 + - job_name: snmp scheme: https tls_config: