From e2fd44eb537f28307a1feaf6578b10bb6b147ba7 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Sat, 6 Oct 2018 22:19:37 +0200 Subject: [PATCH] prometheus: new role --- roles/prometheus/handlers/main.yml | 4 +++ roles/prometheus/tasks/main.yml | 14 ++++++++ roles/prometheus/templates/prometheus.yml.j2 | 35 ++++++++++++++++++++ site.yml | 1 + 4 files changed, 54 insertions(+) create mode 100644 roles/prometheus/handlers/main.yml create mode 100644 roles/prometheus/tasks/main.yml create mode 100644 roles/prometheus/templates/prometheus.yml.j2 diff --git a/roles/prometheus/handlers/main.yml b/roles/prometheus/handlers/main.yml new file mode 100644 index 0000000..38f4e38 --- /dev/null +++ b/roles/prometheus/handlers/main.yml @@ -0,0 +1,4 @@ +--- + +- name: Restart prometheus + service: name=prometheus state=restarted diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml new file mode 100644 index 0000000..1f866a7 --- /dev/null +++ b/roles/prometheus/tasks/main.yml @@ -0,0 +1,14 @@ +--- + +- name: Enable backports for prometheus + apt_repository: repo='deb http://httpredir.debian.org/debian stretch-backports main' + +- name: Install prometheus + apt: name=prometheus default_release='stretch-backports' + +- name: Configure prometheus + template: src=prometheus.yml.j2 dest=/etc/prometheus/prometheus.yml + notify: Restart prometheus + +- name: Enable prometheus + service: name=prometheus state=started enabled=yes diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 new file mode 100644 index 0000000..2e7b942 --- /dev/null +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -0,0 +1,35 @@ +# Sample config for Prometheus. + +global: + scrape_interval: 60s + evaluation_interval: 60s + # scrape_timeout is set to the global default (10s). + + # Attach these labels to any time series or alerts when communicating with + # external systems (federation, remote storage, Alertmanager). + external_labels: + monitor: 'example' + +# Alertmanager configuration +alerting: + alertmanagers: + - static_configs: + - targets: + # - localhost:9093 + +# Load rules once and periodically evaluate them according to the global 'evaluation_interval'. +rule_files: + # - "first_rules.yml" + # - "second_rules.yml" + +# A scrape configuration containing exactly one endpoint to scrape: +# Here it's Prometheus itself. +scrape_configs: +{% if node_targets is defined %} +- job_name: node + static_configs: + - targets: +{% for target in node_targets %} + - {{ target }} +{% endfor %} +{% endif %} diff --git a/site.yml b/site.yml index bcde15e..941fa2b 100644 --- a/site.yml +++ b/site.yml @@ -26,6 +26,7 @@ hosts: nabia.binary.kitchen roles: - librenms + - prometheus - racktables - uau - acme