summaryrefslogtreecommitdiff
path: root/roles/monitoring/prometheus/server
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-06-02 00:46:12 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-06-20 01:44:16 +0200
commit94f56133bb0035fe85ee9e58d573eb4485e9fa42 (patch)
tree88c0f9979faa8e8d7e0d8c0389cd3203514f3a8e /roles/monitoring/prometheus/server
parentprometheus: node exporter automatically select time-sync collector (diff)
prometheus: initial serverside config
Diffstat (limited to 'roles/monitoring/prometheus/server')
-rw-r--r--roles/monitoring/prometheus/server/defaults/main.yml3
-rw-r--r--roles/monitoring/prometheus/server/tasks/main.yml16
-rw-r--r--roles/monitoring/prometheus/server/templates/prometheus.yml.j213
3 files changed, 27 insertions, 5 deletions
diff --git a/roles/monitoring/prometheus/server/defaults/main.yml b/roles/monitoring/prometheus/server/defaults/main.yml
index b5d13b5d..ab08a2ff 100644
--- a/roles/monitoring/prometheus/server/defaults/main.yml
+++ b/roles/monitoring/prometheus/server/defaults/main.yml
@@ -4,3 +4,6 @@
# ...
prometheus_server_retention: "15d"
+
+prometheus_server_jobs:
+ - node
diff --git a/roles/monitoring/prometheus/server/tasks/main.yml b/roles/monitoring/prometheus/server/tasks/main.yml
index ffbc5ffe..5c649f34 100644
--- a/roles/monitoring/prometheus/server/tasks/main.yml
+++ b/roles/monitoring/prometheus/server/tasks/main.yml
@@ -20,16 +20,18 @@
- name: create configuration directories
loop:
+ - jobs
- rules
- targets
file:
path: "/etc/prometheus/{{ item }}"
state: directory
-- name: generate configuration file
- template:
- src: prometheus.yml.j2
- dest: /etc/prometheus/prometheus.yml
+- name: create sub-directroy for all exporter types in jobs directory
+ loop: "{{ prometheus_server_jobs }}"
+ file:
+ path: "/etc/prometheus/jobs/{{ item }}"
+ state: directory
- name: add user for server
user:
@@ -48,6 +50,12 @@
## TODO:
## - create CA and certificate/key
+- name: generate configuration file
+ template:
+ src: prometheus.yml.j2
+ dest: /etc/prometheus/prometheus.yml
+ notify: restart prometheus
+
- name: generate systemd service unit
template:
src: prometheus.service.j2
diff --git a/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 b/roles/monitoring/prometheus/server/templates/prometheus.yml.j2
index cadc3ef0..007afa90 100644
--- a/roles/monitoring/prometheus/server/templates/prometheus.yml.j2
+++ b/roles/monitoring/prometheus/server/templates/prometheus.yml.j2
@@ -8,4 +8,15 @@ rule_files:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- - targets: ['localhost:9090']
+ - targets: ['localhost:9090']
+{% for job in prometheus_server_jobs %}
+
+ - job_name: '{{ job }}'
+ metrics_path: /proxy
+ params:
+ module:
+ - {{ job }}
+ file_sd_configs:
+ - files:
+ - "/etc/prometheus/jobs/{{ job }}/*.yml"
+{% endfor %}