Browse Source

Merge "[prometheus] Support the prometheus openstack exporter"

Zuul 3 months ago
parent
commit
67d496b0e6

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

@@ -304,6 +304,10 @@ prometheus_cadvisor_port: "18080"
304 304
 # Prometheus alertmanager ports
305 305
 prometheus_alertmanager_port: "9093"
306 306
 prometheus_alertmanager_cluster_port: "9094"
307
+
308
+# Prometheus openstack-exporter ports
309
+prometheus_openstack_exporter_port: "9198"
310
+
307 311
 qdrouterd_port: "31459"
308 312
 
309 313
 rabbitmq_port: "5672"
@@ -924,7 +928,10 @@ enable_prometheus_memcached_exporter: "{{ enable_memcached | bool }}"
924 928
 enable_prometheus_cadvisor: "{{ enable_prometheus | bool }}"
925 929
 enable_prometheus_alertmanager: "{{ enable_prometheus | bool }}"
926 930
 enable_prometheus_ceph_mgr_exporter: "{{ enable_ceph | bool and enable_prometheus | bool }}"
931
+enable_prometheus_openstack_exporter: "{{ enable_prometheus | bool }}"
932
+
927 933
 prometheus_alertmanager_user: "admin"
934
+prometheus_openstack_exporter_interval: "60s"
928 935
 
929 936
 ############
930 937
 # Vitrage

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

@@ -729,3 +729,6 @@ storage
729 729
 
730 730
 [prometheus-alertmanager:children]
731 731
 monitoring
732
+
733
+[prometheus-openstack-exporter:children]
734
+monitoring

+ 3
- 0
ansible/inventory/multinode View File

@@ -748,3 +748,6 @@ storage
748 748
 
749 749
 [prometheus-alertmanager:children]
750 750
 monitoring
751
+
752
+[prometheus-openstack-exporter:children]
753
+monitoring

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

@@ -104,6 +104,17 @@ prometheus_services:
104 104
         port: "{{ prometheus_alertmanager_port }}"
105 105
         auth_user: "{{ prometheus_alertmanager_user }}"
106 106
         auth_pass: "{{ prometheus_alertmanager_password }}"
107
+  prometheus-openstack-exporter:
108
+    container_name: "prometheus_openstack_exporter"
109
+    group: "prometheus-openstack-exporter"
110
+    enabled: "{{ enable_prometheus_openstack_exporter | bool }}"
111
+    image: "{{ prometheus_openstack_exporter_image_full }}"
112
+    volumes:
113
+      - "{{ node_config_directory }}/prometheus-openstack-exporter/:{{ container_config_directory }}/:ro"
114
+      - "/etc/localtime:/etc/localtime:ro"
115
+      - "kolla_logs:/var/log/kolla/"
116
+      - "prometheus:/var/lib/prometheus"
117
+    dimensions: "{{ prometheus_openstack_exporter_dimensions }}"
107 118
 
108 119
 ####################
109 120
 # Database
@@ -144,6 +155,10 @@ prometheus_alertmanager_image: "{{ docker_registry ~ '/' if docker_registry else
144 155
 prometheus_alertmanager_tag: "{{ openstack_release }}"
145 156
 prometheus_alertmanager_image_full: "{{ prometheus_alertmanager_image }}:{{ prometheus_alertmanager_tag }}"
146 157
 
158
+# Prometheus openstack_exporter
159
+prometheus_openstack_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-prometheus-openstack-exporter"
160
+prometheus_openstack_exporter_tag: "{{ openstack_release }}"
161
+prometheus_openstack_exporter_image_full: "{{ prometheus_openstack_exporter_image }}:{{ prometheus_openstack_exporter_tag }}"
147 162
 prometheus_server_dimensions: "{{ default_container_dimensions }}"
148 163
 prometheus_haproxy_exporter_dimensions: "{{ default_container_dimensions }}"
149 164
 prometheus_mysqld_exporter_dimensions: "{{ default_container_dimensions }}"
@@ -151,3 +166,4 @@ prometheus_node_exporter_dimensions: "{{ default_container_dimensions }}"
151 166
 prometheus_memcached_exporter_dimensions: "{{ default_container_dimensions }}"
152 167
 prometheus_cadvisor_dimensions: "{{ default_container_dimensions }}"
153 168
 prometheus_alertmanager_dimensions: "{{ default_container_dimensions }}"
169
+prometheus_openstack_exporter_dimensions: "{{ default_container_dimensions }}"

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

@@ -147,3 +147,24 @@
147 147
     - config_json.changed | bool
148 148
       or prometheus_alertmanager_confs.changed | bool
149 149
       or prometheus_container.changed | bool
150
+
151
+- name: Restart prometheus-openstack-exporter container
152
+  vars:
153
+    service_name: "prometheus-openstack-exporter"
154
+    service: "{{ prometheus_services[service_name] }}"
155
+    config_json: "{{ prometheus_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
156
+    prometheus_container: "{{ check_prometheus_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
157
+  kolla_docker:
158
+    action: "recreate_or_restart_container"
159
+    common_options: "{{ docker_common_options }}"
160
+    name: "{{ service.container_name }}"
161
+    image: "{{ service.image }}"
162
+    volumes: "{{ service.volumes }}"
163
+    dimensions: "{{ service.dimensions }}"
164
+  when:
165
+    - kolla_action != "config"
166
+    - inventory_hostname in groups[service.group]
167
+    - service.enabled | bool
168
+    - config_json.changed | bool
169
+      or prometheus_openstack_exporter_confs.changed | bool
170
+      or prometheus_container.changed | bool

+ 17
- 0
ansible/roles/prometheus/tasks/config.yml View File

@@ -106,6 +106,23 @@
106 106
   notify:
107 107
     - Restart prometheus-mysqld-exporter container
108 108
 
109
+- name: Copying cloud config file for openstack exporter
110
+  vars:
111
+    service: "{{ prometheus_services['prometheus-openstack-exporter'] }}"
112
+  template:
113
+    src: "{{ item }}"
114
+    dest: "{{ node_config_directory }}/prometheus-openstack-exporter/clouds.yml"
115
+  register: prometheus_openstack_exporter_confs
116
+  when:
117
+    - inventory_hostname in groups[service.group]
118
+    - service.enabled | bool
119
+  with_first_found:
120
+    - "{{ node_custom_config }}/prometheus-openstack-exporter/{{ inventory_hostname }}/clouds.yml"
121
+    - "{{ node_custom_config }}/prometheus-openstack-exporter/clouds.yml"
122
+    - "{{ role_path }}/templates/clouds.yml.j2"
123
+  notify:
124
+    - Restart prometheus-openstack-exporter container
125
+
109 126
 - name: Check prometheus containers
110 127
   become: true
111 128
   kolla_docker:

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

@@ -9,6 +9,7 @@
9 9
       - prometheus_mysqld_exporter
10 10
       - prometheus_cadvisor
11 11
       - prometheus_alertmanager
12
+      - prometheus_openstack_exporter
12 13
   register: container_facts
13 14
 
14 15
 - name: Checking free port for Prometheus server
@@ -96,3 +97,17 @@
96 97
   with_items:
97 98
     - "{{ prometheus_alertmanager_port }}"
98 99
     - "{{ prometheus_alertmanager_cluster_port }}"
100
+
101
+- name: Checking free ports for Prometheus openstack-exporter
102
+  wait_for:
103
+    host: "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
104
+    port: "{{ item }}"
105
+    connect_timeout: 1
106
+    timeout: 1
107
+    state: stopped
108
+  when:
109
+    - container_facts['prometheus_openstack_exporter'] is not defined
110
+    - inventory_hostname in groups['prometheus-openstack-exporter']
111
+    - enable_prometheus_openstack_exporter | bool
112
+  with_items:
113
+    - "{{ prometheus_openstack_exporter_port }}"

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

@@ -0,0 +1,12 @@
1
+clouds:
2
+ default:
3
+   region_name: {{ openstack_region_name }}
4
+   identity_api_version: 3
5
+   identity_interface: internal
6
+   auth:
7
+     username: {{ keystone_admin_user }}
8
+     password: {{ keystone_admin_password }}
9
+     project_name: {{ keystone_admin_project }}
10
+     project_domain_name: 'Default'
11
+     user_domain_name: 'Default'
12
+     auth_url: {{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }}/v3

+ 23
- 0
ansible/roles/prometheus/templates/prometheus-openstack-exporter.json.j2 View File

@@ -0,0 +1,23 @@
1
+{
2
+    "command": "/opt/openstack-exporter/openstack-exporter --os-client-config=/etc/openstack/clouds.yml --web.listen-address={{ api_interface_address }}:{{ prometheus_openstack_exporter_port }} default",
3
+    "config_files": [
4
+        {
5
+            "source": "{{ container_config_directory }}/clouds.yml",
6
+            "dest": "/etc/openstack/clouds.yml",
7
+            "owner": "prometheus",
8
+            "perm": "0600"
9
+        }
10
+    ],
11
+    "permissions": [
12
+        {
13
+            "path": "/data",
14
+            "owner": "prometheus:kolla",
15
+            "recurse": true
16
+        },
17
+        {
18
+            "path": "/var/log/kolla/prometheus",
19
+            "owner": "prometheus:kolla",
20
+            "recurse": true
21
+        }
22
+    ]
23
+}

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

@@ -75,6 +75,17 @@ scrape_configs:
75 75
 {% endfor %}
76 76
 {% endif %}
77 77
 
78
+{% if enable_prometheus_openstack_exporter | bool %}
79
+  - job_name: openstack_exporter
80
+    scrape_interval: {{ prometheus_openstack_exporter_interval }}
81
+    honor_labels: true
82
+    static_configs:
83
+      - targets:
84
+{% for host in groups["prometheus-openstack-exporter"] %}
85
+        - '{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ hostvars[host]['prometheus_openstack_exporter_port'] }}'
86
+{% endfor %}
87
+{% endif %}
88
+
78 89
 {% if enable_prometheus_alertmanager | bool %}
79 90
 alerting:
80 91
   alertmanagers:

+ 2
- 0
ansible/site.yml View File

@@ -464,6 +464,8 @@
464 464
     - prometheus-mysqld-exporter
465 465
     - prometheus-haproxy-exporter
466 466
     - prometheus-cadvisor
467
+    - prometheus-alertmanager
468
+    - prometheus-openstack-exporter
467 469
     - '&enable_prometheus_True'
468 470
   serial: '{{ kolla_serial|default("0") }}'
469 471
   roles:

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

@@ -543,3 +543,4 @@ tempest_floating_network_name:
543 543
 #enable_prometheus_memcached: "{{ enable_prometheus | bool }}"
544 544
 #enable_prometheus_alertmanager: "{{ enable_prometheus | bool }}"
545 545
 #enable_prometheus_ceph_mgr_exporter: "{{ enable_prometheus | bool and enable_ceph | bool }}"
546
+#enable_prometheus_openstack_exporter: "{{ enable_prometheus | bool }}"

+ 5
- 0
releasenotes/notes/add-prometheus-openstack-exporter-8fd7b0e6c8e71649.yaml View File

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

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

@@ -658,3 +658,6 @@ control
658 658
 compute
659 659
 network
660 660
 storage
661
+
662
+[prometheus-openstack-exporter:children]
663
+monitoring

Loading…
Cancel
Save