Merge "Add support for deploying Prometheus libvirt exporter"

This commit is contained in:
Zuul 2022-02-21 21:35:55 +00:00 committed by Gerrit Code Review
commit 63706667e1
12 changed files with 82 additions and 0 deletions

View File

@ -456,6 +456,7 @@ prometheus_rabbitmq_exporter_port: "{{ rabbitmq_prometheus_port }}"
# Default cadvisor port of 8080 already in use
prometheus_cadvisor_port: "18080"
prometheus_fluentd_integration_port: "24231"
prometheus_libvirt_exporter_port: "9177"
# Prometheus alertmanager ports
prometheus_alertmanager_port: "9093"
@ -1107,6 +1108,7 @@ enable_prometheus_openstack_exporter: "{{ enable_prometheus | bool }}"
enable_prometheus_elasticsearch_exporter: "{{ enable_prometheus | bool and enable_elasticsearch | bool }}"
enable_prometheus_blackbox_exporter: "{{ enable_prometheus | bool }}"
enable_prometheus_rabbitmq_exporter: "{{ enable_prometheus | bool and enable_rabbitmq | bool }}"
enable_prometheus_libvirt_exporter: "{{ enable_prometheus | bool and enable_nova | bool and nova_compute_virt_type in ['kvm', 'qemu'] }}"
prometheus_alertmanager_user: "admin"
prometheus_openstack_exporter_interval: "60s"
@ -1115,6 +1117,7 @@ prometheus_elasticsearch_exporter_interval: "60s"
prometheus_cmdline_extras:
prometheus_ceph_mgr_exporter_endpoints: []
prometheus_openstack_exporter_endpoint_type: "internal"
prometheus_libvirt_exporter_interval: "60s"
############
# Vitrage

View File

@ -699,6 +699,9 @@ elasticsearch
[prometheus-blackbox-exporter:children]
monitoring
[prometheus-libvirt-exporter:children]
compute
[masakari-api:children]
control

View File

@ -717,6 +717,9 @@ elasticsearch
[prometheus-blackbox-exporter:children]
monitoring
[prometheus-libvirt-exporter:children]
compute
[masakari-api:children]
control

View File

@ -92,6 +92,13 @@ prometheus_services:
image: "{{ prometheus_blackbox_exporter_image_full }}"
volumes: "{{ prometheus_blackbox_exporter_default_volumes + prometheus_blackbox_exporter_extra_volumes }}"
dimensions: "{{ prometheus_blackbox_exporter_dimensions }}"
prometheus-libvirt-exporter:
container_name: "prometheus_libvirt_exporter"
group: "prometheus-libvirt-exporter"
enabled: "{{ enable_prometheus_libvirt_exporter | bool }}"
image: "{{ prometheus_libvirt_exporter_image_full }}"
volumes: "{{ prometheus_libvirt_exporter_default_volumes + prometheus_libvirt_exporter_extra_volumes }}"
dimensions: "{{ prometheus_libvirt_exporter_dimensions }}"
####################
# Database
@ -158,6 +165,10 @@ prometheus_blackbox_exporter_image: "{{ docker_registry ~ '/' if docker_registry
prometheus_blackbox_exporter_tag: "{{ prometheus_tag }}"
prometheus_blackbox_exporter_image_full: "{{ prometheus_blackbox_exporter_image }}:{{ prometheus_blackbox_exporter_tag }}"
prometheus_libvirt_exporter_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ prometheus_install_type }}-prometheus-libvirt-exporter"
prometheus_libvirt_exporter_tag: "{{ prometheus_tag }}"
prometheus_libvirt_exporter_image_full: "{{ prometheus_libvirt_exporter_image }}:{{ prometheus_libvirt_exporter_tag }}"
prometheus_server_dimensions: "{{ default_container_dimensions }}"
prometheus_haproxy_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_mysqld_exporter_dimensions: "{{ default_container_dimensions }}"
@ -168,6 +179,7 @@ prometheus_alertmanager_dimensions: "{{ default_container_dimensions }}"
prometheus_openstack_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_elasticsearch_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_blackbox_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_libvirt_exporter_dimensions: "{{ default_container_dimensions }}"
prometheus_server_default_volumes:
- "{{ node_config_directory }}/prometheus-server/:{{ container_config_directory }}/:ro"
@ -228,6 +240,11 @@ prometheus_blackbox_exporter_default_volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
- "kolla_logs:/var/log/kolla/"
prometheus_libvirt_exporter_default_volumes:
- "{{ node_config_directory }}/prometheus-libvirt-exporter/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}"
- "/run/libvirt:/run/libvirt:ro"
prometheus_extra_volumes: "{{ default_extra_volumes }}"
prometheus_server_extra_volumes: "{{ prometheus_extra_volumes }}"
@ -240,6 +257,7 @@ prometheus_alertmanager_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_openstack_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_elasticsearch_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_blackbox_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_libvirt_exporter_extra_volumes: "{{ prometheus_extra_volumes }}"
prometheus_openstack_exporter_disabled_volume: "{{ '--disable-service.volume' if not enable_cinder | bool else '' }}"
prometheus_openstack_exporter_disabled_dns: "{{ '--disable-service.dns' if not enable_designate | bool else '' }}"

View File

@ -149,3 +149,18 @@
dimensions: "{{ service.dimensions }}"
when:
- kolla_action != "config"
- name: Restart prometheus-libvirt-exporter container
vars:
service_name: "prometheus-libvirt-exporter"
service: "{{ prometheus_services[service_name] }}"
become: true
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
dimensions: "{{ service.dimensions }}"
when:
- kolla_action != "config"

View File

@ -19,6 +19,7 @@
- prometheus_openstack_exporter
- prometheus_elasticsearch_exporter
- prometheus_blackbox_exporter
- prometheus_libvirt_exporter
register: container_facts
- name: Checking free port for Prometheus server
@ -149,3 +150,17 @@
- enable_prometheus_blackbox_exporter | bool
with_items:
- "{{ prometheus_blackbox_exporter_port }}"
- name: Checking free ports for Prometheus libvirt-exporter
wait_for:
host: "{{ 'api' | kolla_address }}"
port: "{{ item }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- container_facts['prometheus_libvirt_exporter'] is not defined
- inventory_hostname in groups['prometheus-libvirt-exporter']
- enable_prometheus_libvirt_exporter | bool
with_items:
- "{{ prometheus_libvirt_exporter_port }}"

View File

@ -0,0 +1,4 @@
{
"command": "/opt/libvirt-exporter --web.listen-address={{ api_interface_address }}:{{ prometheus_libvirt_exporter_port }}",
"config_files": []
}

View File

@ -145,6 +145,17 @@ scrape_configs:
replacement: '{{ api_interface_address | put_address_in_context('url') }}:{{ prometheus_blackbox_exporter_port }}'
{% endif %}
{% if enable_prometheus_libvirt_exporter | bool %}
- job_name: libvirt_exporter
scrape_interval: {{ prometheus_libvirt_exporter_interval }}
honor_labels: true
static_configs:
- targets:
{% for host in groups["prometheus-libvirt-exporter"] %}
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_libvirt_exporter_port'] }}'
{% endfor %}
{% endif %}
{% if enable_prometheus_alertmanager | bool %}
- job_name: alertmanager
static_configs:

View File

@ -434,6 +434,7 @@
- prometheus-openstack-exporter
- prometheus-elasticsearch-exporter
- prometheus-blackbox-exporter
- prometheus-libvirt-exporter
- '&enable_prometheus_True'
serial: '{{ kolla_serial|default("0") }}'
roles:

View File

@ -709,6 +709,7 @@
#enable_prometheus_openstack_exporter: "{{ enable_prometheus | bool }}"
#enable_prometheus_elasticsearch_exporter: "{{ enable_prometheus | bool and enable_elasticsearch | bool }}"
#enable_prometheus_blackbox_exporter: "{{ enable_prometheus | bool }}"
#enable_prometheus_libvirt_exporter: "{{ enable_prometheus | bool and enable_nova | bool and nova_compute_virt_type in ['kvm', 'qemu'] }}"
# List of extra parameters passed to prometheus. You can add as many to the list.
#prometheus_cmdline_extras:

View File

@ -0,0 +1,5 @@
---
features:
- |
Deploys and configures a prometheus-libvirt-exporter image as part of the
Prometheus monitoring stack.

View File

@ -770,6 +770,9 @@ elasticsearch
[prometheus-blackbox-exporter:children]
monitoring
[prometheus-libvirt-exporter:children]
compute
# NOTE(yoctozepto): In CI we want to test Masakari HA but not of other services,
# to conserve the resources. Hence, we set Masakari groups to use both
# primary and secondary while the parent group (control) uses only primary.