Skip to content

Commit 61fbf96

Browse files
authored
Merge pull request #167 from stackhpc/victoria-prometheus-targets
Victoria: Prometheus targets
2 parents 131ec61 + 97dbedf commit 61fbf96

File tree

2 files changed

+65
-12
lines changed

2 files changed

+65
-12
lines changed

ansible/roles/prometheus/templates/prometheus.yml.j2

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ global:
22
scrape_interval: 60s
33
scrape_timeout: 10s
44
evaluation_interval: 15s
5-
external_labels:
6-
monitor: 'kolla'
75

86
{% if prometheus_alert_rules.files is defined and prometheus_alert_rules.files | length > 0 %}
97
rule_files:
@@ -17,61 +15,89 @@ scrape_configs:
1715
static_configs:
1816
- targets:
1917
{% for host in groups['prometheus'] %}
20-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ prometheus_port }}'
18+
- '{{ host }}:{{ prometheus_port }}'
2119
{% endfor %}
20+
relabel_configs:
21+
- source_labels: [__address__]
22+
regex: "([^:]+):\\d+"
23+
target_label: instance
2224

2325
{% if enable_prometheus_node_exporter | bool %}
2426
- job_name: node
2527
static_configs:
2628
- targets:
2729
{% for host in groups['prometheus-node-exporter'] %}
28-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_node_exporter_port'] }}'
30+
- '{{ host }}:{{ hostvars[host]['prometheus_node_exporter_port'] }}'
2931
{% endfor %}
32+
relabel_configs:
33+
- source_labels: [__address__]
34+
regex: "([^:]+):\\d+"
35+
target_label: instance
3036
{% endif %}
3137

3238
{% if enable_prometheus_mysqld_exporter | bool %}
3339
- job_name: mysqld
3440
static_configs:
3541
- targets:
3642
{% for host in groups['prometheus-mysqld-exporter'] %}
37-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_mysqld_exporter_port'] }}'
43+
- '{{ host }}:{{ hostvars[host]['prometheus_mysqld_exporter_port'] }}'
3844
{% endfor %}
45+
relabel_configs:
46+
- source_labels: [__address__]
47+
regex: "([^:]+):\\d+"
48+
target_label: instance
3949
{% endif %}
4050

4151
{% if enable_prometheus_haproxy_exporter | bool %}
4252
- job_name: haproxy
4353
static_configs:
4454
- targets:
4555
{% for host in groups['prometheus-haproxy-exporter'] %}
46-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_haproxy_exporter_port'] }}'
56+
- '{{ host }}:{{ hostvars[host]['prometheus_haproxy_exporter_port'] }}'
4757
{% endfor %}
58+
relabel_configs:
59+
- source_labels: [__address__]
60+
regex: "([^:]+):\\d+"
61+
target_label: instance
4862
{% endif %}
4963

5064
{% if enable_prometheus_rabbitmq_exporter | bool %}
5165
- job_name: rabbitmq
5266
static_configs:
5367
- targets:
5468
{% for host in groups['rabbitmq'] %}
55-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_rabbitmq_exporter_port'] }}'
69+
- '{{ host }}:{{ hostvars[host]['prometheus_rabbitmq_exporter_port'] }}'
5670
{% endfor %}
71+
relabel_configs:
72+
- source_labels: [__address__]
73+
regex: "([^:]+):\\d+"
74+
target_label: instance
5775
{% endif %}
5876

5977
{% if enable_prometheus_memcached_exporter | bool %}
6078
- job_name: memcached
6179
static_configs:
6280
- targets:
6381
{% for host in groups['prometheus-memcached-exporter'] %}
64-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_memcached_exporter_port'] }}'
82+
- '{{ host }}:{{ hostvars[host]['prometheus_memcached_exporter_port'] }}'
6583
{% endfor %}
84+
relabel_configs:
85+
- source_labels: [__address__]
86+
regex: "([^:]+):\\d+"
87+
target_label: instance
6688
{% endif %}
6789

6890
{% if enable_prometheus_cadvisor | bool %}
6991
- job_name: cadvisor
7092
static_configs:
7193
- targets:
7294
{% for host in groups["prometheus-cadvisor"] %}
73-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_cadvisor_port'] }}'
95+
- '{{ host }}:{{ hostvars[host]['prometheus_cadvisor_port'] }}'
7496
{% endfor %}
97+
relabel_configs:
98+
- source_labels: [__address__]
99+
regex: "([^:]+):\\d+"
100+
target_label: instance
75101
{% endif %}
76102

77103
{% if enable_prometheus_ceph_mgr_exporter | bool %}
@@ -82,6 +108,10 @@ scrape_configs:
82108
{% for exporter in prometheus_ceph_mgr_exporter_endpoints %}
83109
- '{{ exporter }}'
84110
{% endfor %}
111+
relabel_configs:
112+
- source_labels: [__address__]
113+
regex: "([^:]+):\\d+"
114+
target_label: instance
85115
{% endif %}
86116

87117
{% if enable_prometheus_openstack_exporter | bool %}
@@ -92,8 +122,12 @@ scrape_configs:
92122
static_configs:
93123
- targets:
94124
{% for host in groups["prometheus-openstack-exporter"] %}
95-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_openstack_exporter_port'] }}'
125+
- '{{ host }}:{{ hostvars[host]['prometheus_openstack_exporter_port'] }}'
96126
{% endfor %}
127+
relabel_configs:
128+
- source_labels: [__address__]
129+
regex: "([^:]+):\\d+"
130+
target_label: instance
97131
{% endif %}
98132

99133
{% if enable_prometheus_elasticsearch_exporter | bool %}
@@ -102,8 +136,12 @@ scrape_configs:
102136
static_configs:
103137
- targets:
104138
{% for host in groups["prometheus-elasticsearch-exporter"] %}
105-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_elasticsearch_exporter_port'] }}'
139+
- '{{ host }}:{{ hostvars[host]['prometheus_elasticsearch_exporter_port'] }}'
106140
{% endfor %}
141+
relabel_configs:
142+
- source_labels: [__address__]
143+
regex: "([^:]+):\\d+"
144+
target_label: instance
107145
{% endif %}
108146

109147
{% if enable_prometheus_blackbox_exporter | bool and prometheus_blackbox_exporter_endpoints | length > 0 | bool %}
@@ -137,11 +175,22 @@ scrape_configs:
137175
{% endif %}
138176

139177
{% if enable_prometheus_alertmanager | bool %}
178+
- job_name: alertmanager
179+
static_configs:
180+
- targets:
181+
{% for host in groups['prometheus-alertmanager'] %}
182+
- '{{ host }}:{{ hostvars[host]['prometheus_alertmanager_port'] }}'
183+
{% endfor %}
184+
relabel_configs:
185+
- source_labels: [__address__]
186+
regex: "([^:]+):\\d+"
187+
target_label: instance
188+
140189
alerting:
141190
alertmanagers:
142191
- static_configs:
143192
- targets:
144193
{% for host in groups["prometheus-alertmanager"] %}
145-
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_alertmanager_port'] }}'
194+
- '{{ host }}:{{ hostvars[host]['prometheus_alertmanager_port'] }}'
146195
{% endfor %}
147196
{% endif %}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
Add support for Alertmanager metrics scraping in Prometheus.

0 commit comments

Comments
 (0)