Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

prometheus_alert_rules are not copied as expected #148

Closed
arjuntoor1 opened this issue Oct 4, 2018 · 3 comments
Closed

prometheus_alert_rules are not copied as expected #148

arjuntoor1 opened this issue Oct 4, 2018 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@arjuntoor1
Copy link

arjuntoor1 commented Oct 4, 2018

Hello, I am having problems with setting up default alerts in configuration.

Version: 2.3.3


Expected behaviour

When the prometheus_alert_rules file is populated with some rules, and I then provision the instance, a file should be created in {{ prometheus_config_dir }}/rules/basic.rules containing those rules.

Actual behaviour

The {{ prometheus_config_dir }}/rules/ directory exists but is empty, and Prometheus sees no alerts configured. This occurs even if I simply use the default value for prometheus_alert_rules


Other properties I am using (for example, prometheus_scrape_configs and prometheus_alertmanager_config) seem to work just fine.

@paulfantom
Copy link
Member

paulfantom commented Oct 4, 2018

Alerting rules are copied to {{ prometheus_config_dir }}/rules/ansible_managed.rules when there are two variables set:

  • prometheus_alert_rules
  • prometheus_alertmanager_config

We figured there is no need to create alerting rules when you don't have alertmanager configuration.

This task is responsible for that:

- name: alerting rules file
template:
src: "alert.rules.j2"
dest: "{{ prometheus_config_dir }}/rules/ansible_managed.rules"
owner: root
group: prometheus
mode: 0640
validate: "/usr/local/bin/promtool check rules %s"
when:
- prometheus_alertmanager_config != []
- prometheus_alert_rules != []
notify:
- reload prometheus

@arjuntoor1
Copy link
Author

arjuntoor1 commented Oct 4, 2018

Ah, I see. I had not provided prometheus_alertmanager_config since I was just trying to get the rules written to the file. This morning I moved on to AlertManager and now everything works as expected.

It would be good if it printed a message just like yours, i.e. "no need to create alerting rules when you don't have alertmanager configuration", in this case.

Also, a minor thing, the README states it will be copied to basic.rules but actually it's ansible_managed.rules.

@lock
Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants