Browse Source

Merge "Support the prometheus elasticsearch exporter"

tags/8.0.0.0rc1
Zuul 2 months ago
parent
commit
ce08b31f5e

+ 3
- 0
ansible/group_vars/all.yml View File

@@ -360,6 +360,7 @@ prometheus_alertmanager_cluster_port: "9094"
360 360
 
361 361
 # Prometheus openstack-exporter ports
362 362
 prometheus_openstack_exporter_port: "9198"
363
+prometheus_elasticsearch_exporter_port: "9108"
363 364
 
364 365
 qdrouterd_port: "31459"
365 366
 
@@ -997,9 +998,11 @@ enable_prometheus_cadvisor: "{{ enable_prometheus | bool }}"
997 998
 enable_prometheus_alertmanager: "{{ enable_prometheus | bool }}"
998 999
 enable_prometheus_ceph_mgr_exporter: "{{ enable_ceph | bool and enable_prometheus | bool }}"
999 1000
 enable_prometheus_openstack_exporter: "{{ enable_prometheus | bool }}"
1001
+enable_prometheus_elasticsearch_exporter: "{{ enable_prometheus | bool and enable_elasticsearch | bool }}"
1000 1002
 
1001 1003
 prometheus_alertmanager_user: "admin"
1002 1004
 prometheus_openstack_exporter_interval: "60s"
1005
+prometheus_elasticsearch_exporter_interval: "60s"
1003 1006
 
1004 1007
 ############
1005 1008
 # Vitrage

+ 3
- 0
ansible/inventory/all-in-one View File

@@ -732,3 +732,6 @@ monitoring
732 732
 
733 733
 [prometheus-openstack-exporter:children]
734 734
 monitoring
735
+
736
+[prometheus-elasticsearch-exporter:children]
737
+elasticsearch

+ 3
- 0
ansible/inventory/multinode View File

@@ -751,3 +751,6 @@ monitoring
751 751
 
752 752
 [prometheus-openstack-exporter:children]
753 753
 monitoring
754
+
755
+[prometheus-elasticsearch-exporter:children]
756
+elasticsearch

+ 15
- 0
ansible/roles/prometheus/defaults/main.yml View File

@@ -115,6 +115,16 @@ prometheus_services:
115 115
       - "kolla_logs:/var/log/kolla/"
116 116
       - "prometheus:/var/lib/prometheus"
117 117
     dimensions: "{{ prometheus_openstack_exporter_dimensions }}"
118
+  prometheus-elasticsearch-exporter:
119
+    container_name: prometheus_elasticsearch_exporter
120
+    group: prometheus-elasticsearch-exporter
121
+    enabled: "{{ enable_prometheus_elasticsearch_exporter | bool }}"
122
+    image: "{{ prometheus_elasticsearch_exporter_image_full }}"
123
+    volumes:
124
+      - "{{ node_config_directory }}/prometheus-elasticsearch-exporter/:{{ container_config_directory }}/:ro"
125
+      - "/etc/localtime:/etc/localtime:ro"
126
+      - "kolla_logs:/var/log/kolla/"
127
+    dimensions: "{{ prometheus_elasticsearch_exporter_dimensions }}"
118 128
 
119 129
 ####################
120 130
 # Database
@@ -160,6 +170,10 @@ prometheus_openstack_exporter_image: "{{ docker_registry ~ '/' if docker_registr
160 170
 prometheus_openstack_exporter_tag: "{{ prometheus_tag }}"
161 171
 prometheus_openstack_exporter_image_full: "{{ prometheus_openstack_exporter_image }}:{{ prometheus_openstack_exporter_tag }}"
162 172
 
173
+prometheus_elasticsearch_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-elasticsearch-exporter"
174
+prometheus_elasticsearch_exporter_tag: "{{ prometheus_tag }}"
175
+prometheus_elasticsearch_exporter_image_full: "{{ prometheus_elasticsearch_exporter_image }}:{{ prometheus_elasticsearch_exporter_tag }}"
176
+
163 177
 prometheus_server_dimensions: "{{ default_container_dimensions }}"
164 178
 prometheus_haproxy_exporter_dimensions: "{{ default_container_dimensions }}"
165 179
 prometheus_mysqld_exporter_dimensions: "{{ default_container_dimensions }}"
@@ -168,3 +182,4 @@ prometheus_memcached_exporter_dimensions: "{{ default_container_dimensions }}"
168 182
 prometheus_cadvisor_dimensions: "{{ default_container_dimensions }}"
169 183
 prometheus_alertmanager_dimensions: "{{ default_container_dimensions }}"
170 184
 prometheus_openstack_exporter_dimensions: "{{ default_container_dimensions }}"
185
+prometheus_elasticsearch_exporter_dimensions: "{{ default_container_dimensions }}"

+ 21
- 0
ansible/roles/prometheus/handlers/main.yml View File

@@ -168,3 +168,24 @@
168 168
     - config_json.changed | bool
169 169
       or prometheus_openstack_exporter_confs.changed | bool
170 170
       or prometheus_container.changed | bool
171
+
172
+- name: Restart prometheus-elasticsearch-exporter container
173
+  vars:
174
+    service_name: "prometheus-elasticsearch-exporter"
175
+    service: "{{ prometheus_services[service_name] }}"
176
+    config_json: "{{ prometheus_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
177
+    prometheus_container: "{{ check_prometheus_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
178
+  become: true
179
+  kolla_docker:
180
+    action: "recreate_or_restart_container"
181
+    common_options: "{{ docker_common_options }}"
182
+    name: "{{ service.container_name }}"
183
+    image: "{{ service.image }}"
184
+    volumes: "{{ service.volumes }}"
185
+    dimensions: "{{ service.dimensions }}"
186
+  when:
187
+    - kolla_action != "config"
188
+    - inventory_hostname in groups[service.group]
189
+    - service.enabled | bool
190
+    - config_json.changed | bool
191
+      or prometheus_container.changed | bool

+ 15
- 0
ansible/roles/prometheus/tasks/precheck.yml View File

@@ -10,6 +10,7 @@
10 10
       - prometheus_cadvisor
11 11
       - prometheus_alertmanager
12 12
       - prometheus_openstack_exporter
13
+      - prometheus_elasticsearch_exporter
13 14
   register: container_facts
14 15
 
15 16
 - name: Checking free port for Prometheus server
@@ -111,3 +112,17 @@
111 112
     - enable_prometheus_openstack_exporter | bool
112 113
   with_items:
113 114
     - "{{ prometheus_openstack_exporter_port }}"
115
+
116
+- name: Checking free ports for Prometheus elasticsearch-exporter
117
+  wait_for:
118
+    host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
119
+    port: "{{ item }}"
120
+    connect_timeout: 1
121
+    timeout: 1
122
+    state: stopped
123
+  when:
124
+    - container_facts['prometheus_elasticsearch_exporter'] is not defined
125
+    - inventory_hostname in groups['prometheus-elasticsearch-exporter']
126
+    - enable_prometheus_elasticsearch_exporter | bool
127
+  with_items:
128
+    - "{{ prometheus_elasticsearch_exporter_port }}"

+ 11
- 0
ansible/roles/prometheus/templates/prometheus-elasticsearch-exporter.json.j2 View File

@@ -0,0 +1,11 @@
1
+{
2
+    "command": "/opt/elasticsearch_exporter/elasticsearch_exporter -es.uri http://{{ api_interface_address }}:{{ elasticsearch_port }} -web.listen-address {{ api_interface_address }}:{{ prometheus_elasticsearch_exporter_port }}",
3
+    "config_files": [],
4
+    "permissions": [
5
+        {
6
+            "path": "/var/log/kolla/prometheus",
7
+            "owner": "prometheus:kolla",
8
+            "recurse": true
9
+        }
10
+    ]
11
+}

+ 10
- 0
ansible/roles/prometheus/templates/prometheus.yml.j2 View File

@@ -86,6 +86,16 @@ scrape_configs:
86 86
 {% endfor %}
87 87
 {% endif %}
88 88
 
89
+{% if enable_prometheus_elasticsearch_exporter | bool %}
90
+  - job_name: elasticsearch_exporter
91
+    scrape_interval: {{ prometheus_elasticsearch_exporter_interval }}
92
+    static_configs:
93
+      - targets:
94
+{% for host in groups["prometheus-elasticsearch-exporter"] %}
95
+        - '{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ hostvars[host]['prometheus_elasticsearch_exporter_port'] }}'
96
+{% endfor %}
97
+{% endif %}
98
+
89 99
 {% if enable_prometheus_alertmanager | bool %}
90 100
 alerting:
91 101
   alertmanagers:

+ 1
- 0
ansible/site.yml View File

@@ -466,6 +466,7 @@
466 466
     - prometheus-cadvisor
467 467
     - prometheus-alertmanager
468 468
     - prometheus-openstack-exporter
469
+    - prometheus-elasticsearch-exporter
469 470
     - '&enable_prometheus_True'
470 471
   serial: '{{ kolla_serial|default("0") }}'
471 472
   roles:

+ 1
- 0
etc/kolla/globals.yml View File

@@ -558,3 +558,4 @@ tempest_floating_network_name:
558 558
 #enable_prometheus_alertmanager: "{{ enable_prometheus | bool }}"
559 559
 #enable_prometheus_ceph_mgr_exporter: "{{ enable_prometheus | bool and enable_ceph | bool }}"
560 560
 #enable_prometheus_openstack_exporter: "{{ enable_prometheus | bool }}"
561
+#enable_prometheus_elasticsearch_exporter: "{{ enable_prometheus | bool and enable_elasticsearch | bool }}"

+ 5
- 0
releasenotes/notes/add-prometheus-elasticsearch-exporter-4d9b75b5cb8801d1.yaml View File

@@ -0,0 +1,5 @@
1
+---
2
+features:
3
+  - |
4
+    Deploys and configures the prometheus-elasticsearch-exporter (https://github.com/justwatchcom/elasticsearch_exporter/)
5
+    as part of the prometheus monitoring exporters stack.

+ 3
- 0
tests/templates/inventory.j2 View File

@@ -661,3 +661,6 @@ storage
661 661
 
662 662
 [prometheus-openstack-exporter:children]
663 663
 monitoring
664
+
665
+[prometheus-elasticsearch-exporter:children]
666
+elasticsearch

Loading…
Cancel
Save