summaryrefslogtreecommitdiff
path: root/roles/monitoring/prometheus/server/templates/prometheus.yml.j2
blob: 6db34920c5f649332ea6149af2021c9e73a65b63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# {{ ansible_managed }}

global:
  scrape_interval:     15s
  evaluation_interval: 15s

rule_files:
  - /etc/prometheus/rules/*.yml
{% if prometheus_server_alertmanager is defined %}

alerting:
  alertmanagers:
  - static_configs:
    - targets: ['{{ prometheus_server_alertmanager.url }}']
{%   if 'path_prefix' in prometheus_server_alertmanager %}
    path_prefix: '{{ prometheus_server_alertmanager.path_prefix }}'
{%   endif %}
{% endif %}

scrape_configs:
  - job_name: 'prometheus'
{% if prometheus_server_web_external_url is defined %}
    metrics_path: '{{ (prometheus_server_web_external_url | urlsplit('path'), 'metrics') | path_join }}'
{% endif %}
    static_configs:
    - targets: ['localhost:9090']
      labels:
        instance: "{{ inventory_hostname }}"
{% if prometheus_server_alertmanager is defined %}

  - job_name: 'alertmanager'
{%   if 'path_prefix' in prometheus_server_alertmanager %}
    metrics_path: '{{ (prometheus_server_alertmanager.path_prefix, 'metrics') | path_join }}'
{%   endif %}
    static_configs:
    - targets: ['{{ prometheus_server_alertmanager.url }}']
{% endif %}
{% for job in prometheus_server_jobs %}

  - job_name: '{{ job }}'
    metrics_path: /proxy
    params:
      module:
      - {{ job }}
    scheme: https
    tls_config:
      ca_file: /etc/ssl/prometheus/ca-crt.pem
      cert_file: /etc/ssl/prometheus/server/scrape-crt.pem
      key_file: /etc/ssl/prometheus/server/scrape-key.pem
    file_sd_configs:
    - files:
      - "/etc/prometheus/jobs/{{ job }}/*.yml"
{% endfor %}
{% if prometheus_server_jobs_extra is defined %}

  {{ prometheus_server_jobs_extra | indent(2) }}
{% endif %}