From cc3b4294aea94b8dae863199d6401de544933a73 Mon Sep 17 00:00:00 2001 From: pz2891 Date: Fri, 20 Aug 2021 19:31:04 +0200 Subject: [PATCH] Kepp federated datas 4 months (120 days) --- roles/prometheus/tasks/main.yml | 1 + .../templates/environmental.rules.yml.j2 | 52 +++++++++++++++++++ roles/prometheus_federate/tasks/main.yml | 7 +++ 3 files changed, 60 insertions(+) create mode 100644 roles/prometheus/templates/environmental.rules.yml.j2 diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml index 790c108..f9e48e8 100644 --- a/roles/prometheus/tasks/main.yml +++ b/roles/prometheus/tasks/main.yml @@ -41,6 +41,7 @@ - django.rules.yml - ups.rules.yml - postgres.rules.yml + - environmental.rules.yml notify: Restart Prometheus - name: Make Prometheus snmp-exporter listen on localhost only diff --git a/roles/prometheus/templates/environmental.rules.yml.j2 b/roles/prometheus/templates/environmental.rules.yml.j2 new file mode 100644 index 0000000..f371329 --- /dev/null +++ b/roles/prometheus/templates/environmental.rules.yml.j2 @@ -0,0 +1,52 @@ +--- +{{ ansible_managed | comment }} + +{% macro raw(string) -%} +{{ "{{" }} {{ string }} {{ "}}" }} +{%- endmacro %} + +groups: + + - name: environmental.rules + rules: + + - alert: EnvironmentalTemperature + expr: rPDU2SensorTempHumidityStatusTempC / 10 > 30 + for: 10m + labels: + severity: warning + annotations: + summary: >- + Température environnementale à {{ raw('$value') }}° + + - alert: EnvironmentalTemperature + expr: rPDU2SensorTempHumidityStatusTempC / 10 > 40 + for: 10m + labels: + severity: critical + annotations: + summary: >- + Température environnementale à {{ raw('$value') }}° + + + - alert: EnvironmentalTemperature + expr: xupsEnvRemoteTemp > 30 + for: 10m + labels: + severity: warning + annotations: + summary: >- + Température environnementale à {{ raw('$value') }}° + + - alert: EnvironmentalTemperature + expr: xupsEnvRemoteTemp > 40 + for: 10m + labels: + severity: critical + annotations: + summary: >- + Température environnementale à {{ raw('$value') }}° + + + +... diff --git a/roles/prometheus_federate/tasks/main.yml b/roles/prometheus_federate/tasks/main.yml index cc96e65..366f614 100644 --- a/roles/prometheus_federate/tasks/main.yml +++ b/roles/prometheus_federate/tasks/main.yml @@ -20,6 +20,13 @@ - alert.rules.yml notify: Restart Prometheus +- name: Define Prometheus retention time + lineinfile: + path: /etc/default/prometheus + regexp: '^ARGS=\"--log.level=debug\"' + line: "ARGS=\"--log.level=debug --storage.tsdb.retention.time=120d\"" + notify: Restart Prometheus + # We don't need to restart Prometheus when updating nodes - name: Configure Prometheus Federate devices copy: