From deae3a4324530220511a7e156050c32a8fcd7c5c Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Wed, 1 May 2024 16:24:12 +0200 Subject: [PATCH] Set up Prometheus alerting on Netcup --- ansible/roles/prometheus/defaults/main.yml | 6 ++++-- ansible/roles/prometheus/tasks/main.yml | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ansible/roles/prometheus/defaults/main.yml b/ansible/roles/prometheus/defaults/main.yml index fbefe918..fc2da504 100644 --- a/ansible/roles/prometheus/defaults/main.yml +++ b/ansible/roles/prometheus/defaults/main.yml @@ -19,8 +19,7 @@ prometheus_configuration: # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: - # - "first_rules.yml" - # - "second_rules.yml" + - "rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. @@ -43,3 +42,6 @@ prometheus_configuration: # machine by default. static_configs: - targets: ['localhost:9100'] + +prometheus_rules: + groups: [] diff --git a/ansible/roles/prometheus/tasks/main.yml b/ansible/roles/prometheus/tasks/main.yml index b1bb67ad..797d8a5a 100644 --- a/ansible/roles/prometheus/tasks/main.yml +++ b/ansible/roles/prometheus/tasks/main.yml @@ -31,3 +31,17 @@ - role::prometheus notify: - Reload the prometheus service + +- name: Configure prometheus rules + copy: + content: | + # Ansible managed + {{ prometheus_rules | to_nice_yaml }} + dest: /etc/prometheus/rules.yml + owner: prometheus + group: prometheus + mode: "0400" + tags: + - role::prometheus + notify: + - Reload the prometheus service