diff options
| -rw-r--r-- | ansible/roles/prometheus/defaults/main.yml | 6 | ||||
| -rw-r--r-- | 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 fbefe91..fc2da50 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 b1bb67a..797d8a5 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 | 
