blob: 09d5452dff49620dd28c7a68f1b3068ca4ec2516 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# {{ ansible_managed }}
global:
scrape_interval: {{ prometheus_server_scrape_interval }}
evaluation_interval: {{ prometheus_server_evaluation_interval }}
{% if prometheus_server_external_labels is defined %}
external_labels:
{% for name, value in prometheus_server_external_labels.items() %}
{{ name }}: {{ value }}
{% endfor %}
{% endif %}
rule_files:
- /etc/prometheus/rules/*.yml
{% for subdir in (prometheus_server_jobs | select('match', '.*/.*') | map('dirname') | unique) %}
- /etc/prometheus/rules/{{ subdir }}/*.yml
{% endfor %}
{% 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 %}
{% 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:
- job_name: 'prometheus'
{% if prometheus_server_web_route_prefix is defined or prometheus_server_web_external_url is defined %}
metrics_path: '{{ (prometheus_server_web_route_prefix | default(prometheus_server_web_external_url | default('') | urlsplit('path')), 'metrics') | path_join }}'
{% endif %}
{% if prometheus_server_selfscraping_auth is defined %}
basic_auth:
username: '{{ prometheus_server_selfscraping_auth.username }}'
password_file: '/etc/prometheus/prometheus-selfscraping.password'
{% 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 %}
{% 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 }}']
{% endif %}
{% for job in (prometheus_server_jobs) %}
{% include lookup('first_found', {'paths': ['templates/jobs'], 'files': [job + '.j2', 'generic.j2']}) | relpath(template_fullpath | dirname) %}{{ '' }}
{% endfor %}
{% if prometheus_server_jobs_extra is defined %}
{{ prometheus_server_jobs_extra | indent(2) }}
{% endif %}
{% for source, config in (prometheus_server_federation | default({})).items() %}
## federation: {{ source }}
{% for job in config.jobs %}
- job_name: 'federate/{{ source }}/{{ job }}'
scrape_interval: 15s
scrape_timeout: 15s
scheme: {{ config.scheme | default('https') }}
metrics_path: {{ config.path_prefix | default('') }}/federate
{% if 'basic_auth' in config %}
basic_auth:
username: '{{ config.basic_auth.username }}'
password_file: '/etc/prometheus/prometheus-federation-{{ source }}.password'
{% endif %}
honor_labels: true
metric_relabel_configs:
- source_labels: [id]
regex: '^static-agent$'
action: drop
params:
match[]:
- '{job="{{ job }}"}'
static_configs:
- targets: ['{{ config.url }}']
{% endfor %}
{% endfor %}
|