Add option to enable proxysql's prometheus exporter

From version 2.1, ProxySQL has a built-in ProxySQL
Prometheus exporter. This patch adds an option to
easily enable this exporter [1].

[1] https://proxysql.com/documentation/prometheus-exporter

Change-Id: I8776cdc0a6ec9e4e35a2424dd0984488514a711f
This commit is contained in:
Michal Arbet 2024-09-09 16:52:31 +02:00
parent 03122599ee
commit de79f77ef0
8 changed files with 70 additions and 0 deletions

View File

@ -584,6 +584,7 @@ prometheus_cadvisor_port: "18080"
prometheus_fluentd_integration_port: "24231" prometheus_fluentd_integration_port: "24231"
prometheus_libvirt_exporter_port: "9177" prometheus_libvirt_exporter_port: "9177"
prometheus_etcd_integration_port: "{{ etcd_client_port }}" prometheus_etcd_integration_port: "{{ etcd_client_port }}"
proxysql_prometheus_exporter_port: "6070"
# Prometheus alertmanager ports # Prometheus alertmanager ports
prometheus_alertmanager_internal_fqdn: "{{ kolla_internal_fqdn }}" prometheus_alertmanager_internal_fqdn: "{{ kolla_internal_fqdn }}"
@ -1237,6 +1238,7 @@ enable_prometheus_blackbox_exporter: "{{ enable_prometheus | bool }}"
enable_prometheus_rabbitmq_exporter: "{{ enable_prometheus | bool and enable_rabbitmq | 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'] }}" enable_prometheus_libvirt_exporter: "{{ enable_prometheus | bool and enable_nova | bool and nova_compute_virt_type in ['kvm', 'qemu'] }}"
enable_prometheus_etcd_integration: "{{ enable_prometheus | bool and enable_etcd | bool }}" enable_prometheus_etcd_integration: "{{ enable_prometheus | bool and enable_etcd | bool }}"
enable_prometheus_proxysql_exporter: "{{ enable_prometheus | bool and enable_proxysql | bool }}"
prometheus_alertmanager_user: "admin" prometheus_alertmanager_user: "admin"
prometheus_ceph_exporter_interval: "{{ prometheus_scrape_interval }}" prometheus_ceph_exporter_interval: "{{ prometheus_scrape_interval }}"

View File

@ -162,6 +162,9 @@ proxysql_backend_max_replication_lag: "0"
proxysql_admin_user: "kolla-admin" proxysql_admin_user: "kolla-admin"
proxysql_stats_user: "kolla-stats" proxysql_stats_user: "kolla-stats"
# Proxysql prometheus exporter
proxysql_prometheus_exporter_memory_metrics_interval: "60"
# Default timeout values # Default timeout values
haproxy_http_request_timeout: "10s" haproxy_http_request_timeout: "10s"
haproxy_http_keep_alive_timeout: "10s" haproxy_http_keep_alive_timeout: "10s"

View File

@ -190,6 +190,33 @@
- inventory_hostname in groups['loadbalancer'] - inventory_hostname in groups['loadbalancer']
- api_interface_address != kolla_internal_vip_address - api_interface_address != kolla_internal_vip_address
- name: Checking free port for ProxySQL prometheus exporter (api interface)
wait_for:
host: "{{ api_interface_address }}"
port: "{{ proxysql_prometheus_exporter_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- enable_proxysql | bool
- enable_prometheus_proxysql_exporter | bool
- container_facts['proxysql'] is not defined
- inventory_hostname in groups['loadbalancer']
- name: Checking free port for ProxySQL prometheus exporter (vip interface)
wait_for:
host: "{{ kolla_internal_vip_address }}"
port: "{{ proxysql_prometheus_exporter_port }}"
connect_timeout: 1
timeout: 1
state: stopped
when:
- enable_proxysql | bool
- enable_prometheus_proxysql_exporter | bool
- proxysql_vip_prechecks
- inventory_hostname in groups['loadbalancer']
- api_interface_address != kolla_internal_vip_address
# FIXME(yoctozepto): this req seems arbitrary, they need not be, just routable is fine # FIXME(yoctozepto): this req seems arbitrary, they need not be, just routable is fine
- name: Checking if kolla_internal_vip_address is in the same network as api_interface on all nodes - name: Checking if kolla_internal_vip_address is in the same network as api_interface on all nodes
become: true become: true

View File

@ -12,6 +12,9 @@ admin_variables:
admin_credentials: "{{ proxysql_admin_user }}:{{ proxysql_admin_password }}" admin_credentials: "{{ proxysql_admin_user }}:{{ proxysql_admin_password }}"
mysql_ifaces: "{{ api_interface_address }}:{{ proxysql_admin_port }};{{ kolla_internal_vip_address }}:{{ proxysql_admin_port }};/var/lib/kolla/proxysql/admin.sock" mysql_ifaces: "{{ api_interface_address }}:{{ proxysql_admin_port }};{{ kolla_internal_vip_address }}:{{ proxysql_admin_port }};/var/lib/kolla/proxysql/admin.sock"
stats_credentials: "{{ proxysql_stats_user }}:{{ proxysql_stats_password }}" stats_credentials: "{{ proxysql_stats_user }}:{{ proxysql_stats_password }}"
restapi_enabled: "{{ enable_prometheus_proxysql_exporter | bool }}"
restapi_port: "{{ proxysql_prometheus_exporter_port }}"
prometheus_memory_metrics_interval: "{{ proxysql_prometheus_exporter_memory_metrics_interval }}"
mysql_variables: mysql_variables:
threads: {{ proxysql_workers }} threads: {{ proxysql_workers }}

View File

@ -252,6 +252,19 @@ scrape_configs:
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if enable_prometheus_proxysql_exporter | bool %}
- job_name: proxysql
static_configs:
{% for host in groups["loadbalancer"] %}
- targets:
- '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['proxysql_prometheus_exporter_port'] }}'
{% if hostvars[host].prometheus_instance_label | default(false, true) %}
labels:
instance: "{{ hostvars[host].prometheus_instance_label }}"
{% endif %}
{% endfor %}
{% endif %}
alerting: alerting:
alertmanagers: alertmanagers:
- static_configs: - static_configs:

View File

@ -0,0 +1,7 @@
---
features:
- |
Add ``proxysql_prometheus_exporter`` configuration parameter which
can be used to configure Prometheus to scrape ProxySQL metrics endpoints.
The default value of ``proxysql_prometheus_exporter`` is set to
the combined values of ``enable_prometheus`` and ``enable_proxysql``.

View File

@ -129,6 +129,7 @@ enable_masakari: "yes"
{% if scenario == "cells" %} {% if scenario == "cells" %}
enable_cells: "yes" enable_cells: "yes"
enable_proxysql: "yes" enable_proxysql: "yes"
enable_prometheus_proxysql_exporter: "yes"
{% endif %} {% endif %}
{% if scenario == "mariadb" %} {% if scenario == "mariadb" %}

View File

@ -481,6 +481,19 @@ function test_internal_dns_integration {
fi fi
} }
function test_proxysql_prometheus_exporter {
if [[ $SCENARIO == "cells" ]]; then
if curl -v http://127.0.0.1:6070/metrics 2>/dev/null | grep '^proxysql_'; then
echo "[i] Proxysql prometheus exporter - PASS"
mkdir -p /tmp/logs/prometheus-exporters/proxysql
curl -v http://127.0.0.1:6070/metrics 2>/dev/null -o /tmp/logs/prometheus-exporters/proxysql/exporter.txt
else
echo "[e] Proxysql prometheus exporter - FAIL"
exit 1
fi
fi
}
function test_openstack_logged { function test_openstack_logged {
. /etc/kolla/admin-openrc.sh . /etc/kolla/admin-openrc.sh
. ~/openstackclient-venv/bin/activate . ~/openstackclient-venv/bin/activate
@ -488,6 +501,7 @@ function test_openstack_logged {
test_neutron_modules test_neutron_modules
test_instance_boot test_instance_boot
test_internal_dns_integration test_internal_dns_integration
test_proxysql_prometheus_exporter
# Check for x86_64 architecture to run q35 tests # Check for x86_64 architecture to run q35 tests
if [[ $(uname -m) == "x86_64" ]]; then if [[ $(uname -m) == "x86_64" ]]; then