diff options
Diffstat (limited to 'roles/prometheus')
-rw-r--r-- | roles/prometheus/defaults/main.yml | 1 | ||||
-rw-r--r-- | roles/prometheus/tasks/main.yml | 23 | ||||
-rw-r--r-- | roles/prometheus/templates/prometheus.conf.j2 | 21 |
3 files changed, 45 insertions, 0 deletions
diff --git a/roles/prometheus/defaults/main.yml b/roles/prometheus/defaults/main.yml new file mode 100644 index 0000000..fa8c55f --- /dev/null +++ b/roles/prometheus/defaults/main.yml @@ -0,0 +1 @@ +prometheus_configuration_file: /etc/prometheus/prometheus.yml diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml new file mode 100644 index 0000000..5d5c1f3 --- /dev/null +++ b/roles/prometheus/tasks/main.yml @@ -0,0 +1,23 @@ +- name: install prometheus + package: + name: + - prometheus + - node_exporter + state: present + +- name: generate prometheus configuration + template: + src: prometheus.conf.j2 + dest: "{{ prometheus_configuration_file }}" + owner: 0 + group: 0 + mode: 0644 + +- name: enable and restart prometheus services + service: + name: "{{ item }}" + state: restarted + enabled: true + loop: + - prometheus + - node_exporter diff --git a/roles/prometheus/templates/prometheus.conf.j2 b/roles/prometheus/templates/prometheus.conf.j2 new file mode 100644 index 0000000..7402dd2 --- /dev/null +++ b/roles/prometheus/templates/prometheus.conf.j2 @@ -0,0 +1,21 @@ +# managed by Ansible + +global: + scrape_interval: 15s + evaluation_interval: 15s + +alerting: + alertmanagers: + - static_configs: + - targets: + +rule_files: + +scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["127.0.0.1:9090"] + - job_name: "node_exporter" + scrape_interval: 5s + static_configs: + - targets: ["127.0.0.1:9100"] |