From 187894ff0d651f0f9924df9a40bc1085f4172612 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 27 Oct 2021 23:30:04 +0200 Subject: prometheus add basic auth to alert-manager --- .../prometheus/server/templates/prometheus.service.j2 | 2 +- roles/monitoring/prometheus/server/templates/prometheus.yml.j2 | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'roles/monitoring/prometheus/server/templates') diff --git a/roles/monitoring/prometheus/server/templates/prometheus.service.j2 b/roles/monitoring/prometheus/server/templates/prometheus.service.j2 index b21cceae..77a3b02a 100644 --- a/roles/monitoring/prometheus/server/templates/prometheus.service.j2 +++ b/roles/monitoring/prometheus/server/templates/prometheus.service.j2 @@ -6,7 +6,7 @@ After=time-sync.target [Service] Restart=on-failure User=prometheus -ExecStart=/usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/metrics2/ --storage.tsdb.retention.time={{ prometheus_server_retention }}{% if prometheus_server_web_external_url is defined %} --web.external-url={{ prometheus_server_web_external_url }}{% endif %}{% if prometheus_server_auth_users is defined %} --web.config.file /etc/prometheus/prometheus-web.yml{% endif %} --web.listen-address={{ prometheus_server_web_listen_address }} +ExecStart=/usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/metrics2/ --storage.tsdb.retention.time={{ prometheus_server_retention }}{% if prometheus_server_web_external_url is defined %} --web.external-url={{ prometheus_server_web_external_url }}{% endif %}{% if prometheus_server_auth_users is defined %} --web.config.file=/etc/prometheus/prometheus-web.yml{% endif %} --web.listen-address={{ prometheus_server_web_listen_address }} ExecReload=/bin/kill -HUP $MAINPID TimeoutStopSec=20s SendSIGKILL=no diff --git a/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 b/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 index e73ca354..98ac1aaa 100644 --- a/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 +++ b/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 @@ -18,6 +18,11 @@ alerting: {% if 'path_prefix' in prometheus_server_alertmanager %} path_prefix: '{{ prometheus_server_alertmanager.path_prefix }}' {% endif %} +{% if 'basic_auth' in prometheus_server_alertmanager %} + basic_auth: + username: '{{ prometheus_server_alertmanager.basic_auth.username }}' + password_file: '/etc/prometheus/prometheus-alertmanager.password' +{% endif %} {% endif %} scrape_configs: @@ -34,6 +39,11 @@ scrape_configs: - job_name: 'alertmanager' {% if 'path_prefix' in prometheus_server_alertmanager %} metrics_path: '{{ (prometheus_server_alertmanager.path_prefix, 'metrics') | path_join }}' +{% endif %} +{% if 'basic_auth' in prometheus_server_alertmanager %} + basic_auth: + username: '{{ prometheus_server_alertmanager.basic_auth.username }}' + password_file: '/etc/prometheus/prometheus-alertmanager.password' {% endif %} static_configs: - targets: ['{{ prometheus_server_alertmanager.url }}'] -- cgit v1.2.3