summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/cephadm/templates/services/prometheus/prometheus.yml.j2
blob: 961da145dac639ec8ad3ce22b142dcdfe742b378 (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# {{ cephadm_managed }}
global:
  scrape_interval: 10s
  evaluation_interval: 10s
  external_labels:
    cluster: {{ cluster_fsid }}

rule_files:
  - /etc/prometheus/alerting/*

{% if alertmanager_sd_url %}
alerting:
  alertmanagers:
{% if security_enabled %}
    - scheme: https
      basic_auth:
        username: {{ alertmanager_web_user }}
        password: {{ alertmanager_web_password }}
      tls_config:
        ca_file: root_cert.pem
        cert_file: prometheus.crt
        key_file:  prometheus.key
      path_prefix: '{{ alertmanager_url_prefix }}'
      http_sd_configs:
        - url: {{ alertmanager_sd_url }}
          basic_auth:
            username: {{ service_discovery_username }}
            password: {{ service_discovery_password }}
          tls_config:
            ca_file: root_cert.pem
            cert_file: prometheus.crt
            key_file:  prometheus.key
{% else %}
    - scheme: http
      http_sd_configs:
        - url: {{ alertmanager_sd_url }}
{% endif %}
{% endif %}

scrape_configs:
  - job_name: 'ceph'
    relabel_configs:
    - source_labels: [__address__]
      target_label: cluster
      replacement: {{ cluster_fsid }}
    - source_labels: [instance]
      target_label: instance
      replacement: 'ceph_cluster'
{% if security_enabled %}
    scheme: https
    tls_config:
      ca_file: root_cert.pem
    honor_labels: true
    http_sd_configs:
    - url: {{ mgr_prometheus_sd_url }}
      basic_auth:
        username: {{ service_discovery_username }}
        password: {{ service_discovery_password }}
      tls_config:
        ca_file: root_cert.pem
        cert_file: prometheus.crt
        key_file:  prometheus.key
{% else %}
    honor_labels: true
    http_sd_configs:
    - url: {{ mgr_prometheus_sd_url }}
{% endif %}

{% if node_exporter_sd_url %}
  - job_name: 'node'
    relabel_configs:
    - source_labels: [__address__]
      target_label: cluster
      replacement: {{ cluster_fsid }}
{% if security_enabled %}
    scheme: https
    tls_config:
      ca_file: root_cert.pem
      cert_file: prometheus.crt
      key_file:  prometheus.key
    http_sd_configs:
    - url: {{ node_exporter_sd_url }}
      basic_auth:
        username: {{ service_discovery_username }}
        password: {{ service_discovery_password }}
      tls_config:
        ca_file: root_cert.pem
        cert_file: prometheus.crt
        key_file:  prometheus.key
{% else %}
    http_sd_configs:
    - url: {{ node_exporter_sd_url }}
{% endif %}
{% endif %}

{% if haproxy_sd_url %}
  - job_name: 'haproxy'
    relabel_configs:
    - source_labels: [__address__]
      target_label: cluster
      replacement: {{ cluster_fsid }}
{% if security_enabled %}
    scheme: https
    tls_config:
      ca_file: root_cert.pem
    http_sd_configs:
    - url: {{ haproxy_sd_url }}
      basic_auth:
        username: {{ service_discovery_username }}
        password: {{ service_discovery_password }}
      tls_config:
        ca_file: root_cert.pem
        cert_file: prometheus.crt
        key_file:  prometheus.key
{% else %}
    http_sd_configs:
    - url: {{ haproxy_sd_url }}
{% endif %}
{% endif %}

{% if ceph_exporter_sd_url %}
  - job_name: 'ceph-exporter'
    relabel_configs:
    - source_labels: [__address__]
      target_label: cluster
      replacement: {{ cluster_fsid }}
{% if security_enabled %}
    honor_labels: true
    scheme: https
    tls_config:
      ca_file: root_cert.pem
    http_sd_configs:
    - url: {{ ceph_exporter_sd_url }}
      basic_auth:
        username: {{ service_discovery_username }}
        password: {{ service_discovery_password }}
      tls_config:
        ca_file: root_cert.pem
        cert_file: prometheus.crt
        key_file:  prometheus.key
{% else %}
    honor_labels: true
    http_sd_configs:
    - url: {{ ceph_exporter_sd_url }}
{% endif %}
{% endif %}

{% if nvmeof_sd_url %}
  - job_name: 'nvmeof'
{% if security_enabled %}
    honor_labels: true
    scheme: https
    tls_config:
      ca_file: root_cert.pem
    http_sd_configs:
    - url: {{ nvmeof_sd_url }}
      basic_auth:
        username: {{ service_discovery_username }}
        password: {{ service_discovery_password }}
      tls_config:
        ca_file: root_cert.pem
        cert_file: prometheus.crt
        key_file:  prometheus.key
{% else %}
    http_sd_configs:
    - url: {{ nvmeof_sd_url }}
{% endif %}
{% endif %}

{% if nfs_sd_url %}
  - job_name: 'nfs'
{% if security_enabled %}
    honor_labels: true
    scheme: https
    tls_config:
      ca_file: root_cert.pem
    http_sd_configs:
    - url: {{ nfs_sd_url }}
      basic_auth:
        username: {{ service_discovery_username }}
        password: {{ service_discovery_password }}
      tls_config:
        ca_file: root_cert.pem
        cert_file: prometheus.crt
        key_file:  prometheus.key
{% else %}
    http_sd_configs:
    - url: {{ nfs_sd_url }}
{% endif %}
{% endif %}

{% if smb_sd_url %}
  - job_name: 'smb'
{% if security_enabled %}
    honor_labels: true
    scheme: https
    tls_config:
      ca_file: root_cert.pem
    http_sd_configs:
    - url: {{ smb_sd_url }}
      basic_auth:
        username: {{ service_discovery_username }}
        password: {{ service_discovery_password }}
      tls_config:
        ca_file: root_cert.pem
        cert_file: prometheus.crt
        key_file:  prometheus.key
{% else %}
    http_sd_configs:
    - url: {{ smb_sd_url }}
{% endif %}
{% endif %}

{% for url, details in clusters_credentials.items() %}
  - job_name: 'federate_{{ loop.index }}'
    scrape_interval: 15s
    honor_labels: true
    metrics_path: {{ federate_path }}
    relabel_configs:
    - source_labels: [__address__]
      target_label: cluster
      replacement: {{ cluster_fsid }}
{% if security_enabled %}
    scheme: https
    tls_config:
      ca_file: {{ details['cert_file_name'] }}
    basic_auth:
      username: {{ details['user'] }}
      password: {{ details['password'] }}
{% endif %}
    params:
      'match[]':
        - '{job="ceph"}'
        - '{job="node"}'
        - '{job="haproxy"}'
        - '{job="ceph-exporter"}'
    static_configs:
    - targets: ['{{ url }}']
{% endfor %}