Skip to content

Commit

Permalink
enhancement(prometheus): handle yaml formatted files with the old .ru…
Browse files Browse the repository at this point in the history
…les extension

Signed-off-by: dpavle <[email protected]>
  • Loading branch information
dpavle committed Apr 18, 2024
1 parent b8e4f31 commit a7b4409
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions roles/prometheus/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@
- prometheus_alertmanager_config == []
- prometheus_alert_rules != []

- name: Alert when alert rules files are found in the old .rules format

Check failure on line 92 in roles/prometheus/tasks/preflight.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

ignore-errors

Use failed_when and specify error conditions instead of using ignore_errors.
ansible.builtin.debug:
msg: >
prometheus_alert_rules_files contains rules in the old .rules file format.
This format has been deprecated in favour of the new YAML format since Prometheus v2.x.
You can update your rules using promtool: promtool update rules <filenames>
If your rules are already in the YAML format but with the .rules extension, you can safely ignore this message,
or rename the files to <filename>.yaml or <filename>.yml to get rid of it.
when: prometheus_alert_rules_files | select('search', '.rules$') | list | length > 0
ignore_errors: true

- name: Discover latest version
ansible.builtin.set_fact:
prometheus_version: "{{ (lookup('url', 'https://api.github.com/repos/{{ _prometheus_repo}}/releases/latest', headers=_github_api_headers,
Expand Down
1 change: 1 addition & 0 deletions roles/prometheus/templates/prometheus.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ remote_read:
rule_files:
- {{ prometheus_config_dir }}/rules/*.yml
- {{ prometheus_config_dir }}/rules/*.yaml
- {{ prometheus_config_dir }}/rules/*.rules
{% endif %}

{% if prometheus_alertmanager_config | length > 0 %}
Expand Down

0 comments on commit a7b4409

Please sign in to comment.