From 0fa8299c2bea686424d11970ea978ef242171f45 Mon Sep 17 00:00:00 2001 From: Guido Grazioli Date: Thu, 23 Jun 2022 22:32:13 +0200 Subject: [PATCH] Add prometheus metrics export plugin --- roles/amq_broker/README.md | 4 ++++ roles/amq_broker/defaults/main.yml | 3 ++- roles/amq_broker/meta/argument_specs.yml | 4 ++++ roles/amq_broker/tasks/configure.yml | 9 ++++++++ roles/amq_broker/tasks/systemd.yml | 26 ++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/roles/amq_broker/README.md b/roles/amq_broker/README.md index 40c21c91..da2ea069 100644 --- a/roles/amq_broker/README.md +++ b/roles/amq_broker/README.md @@ -133,6 +133,10 @@ Role Defaults |`amq_broker_disable_hornetq_protocol`| Whether to disable HORNETQ protocol | `False` | |`amq_broker_disable_mqtt_protocol`| Whether to disable MQTT protocol | `False` | |`amq_broker_disable_stomp_protocol`| Whether to disable STOMP protocol | `False` | +|`amq_broker_jmx_exporter_port` | Port for prometheus JMX exporter to listen | `18080` | +|`amq_broker_jmx_exporter_config_path`| JMX exporter configuration path |`{{ amq_broker_dest }}/{{ amq_broker_instance_name }}/etc/jmx_exporter.yml` | +|`amq_broker_jmx_exporter_enabled`| Enable install and configuration of prometheus-jmx-exporter | `False` | +|`amq_broker_prometheus_enabled`| Enable install and configuration of prometheus metrics plugin | `False` | Role Variables diff --git a/roles/amq_broker/defaults/main.yml b/roles/amq_broker/defaults/main.yml index 48121f3e..0540e8b9 100644 --- a/roles/amq_broker/defaults/main.yml +++ b/roles/amq_broker/defaults/main.yml @@ -101,7 +101,8 @@ amq_broker_logger_jetty_level: WARN amq_broker_logger_curator_level: WARN amq_broker_logger_zookeeper_level: ERROR -# Misc +# Metrics amq_broker_jmx_exporter_port: 18080 amq_broker_jmx_exporter_config_path: "{{ amq_broker_dest }}/{{ amq_broker_instance_name }}/etc/jmx_exporter.yml" amq_broker_jmx_exporter_enabled: False +amq_broker_prometheus_enabled: False \ No newline at end of file diff --git a/roles/amq_broker/meta/argument_specs.yml b/roles/amq_broker/meta/argument_specs.yml index 05398ef6..fbb5da9f 100644 --- a/roles/amq_broker/meta/argument_specs.yml +++ b/roles/amq_broker/meta/argument_specs.yml @@ -375,3 +375,7 @@ argument_specs: description: "Enable install and configuration of prometheus-jmx-exporter" default: False type: "bool" + amq_broker_prometheus_enabled: + description: "Enable install and configuration of prometheus metrics plugin" + default: False + type: "bool" \ No newline at end of file diff --git a/roles/amq_broker/tasks/configure.yml b/roles/amq_broker/tasks/configure.yml index 62e4d847..ff7d0262 100644 --- a/roles/amq_broker/tasks/configure.yml +++ b/roles/amq_broker/tasks/configure.yml @@ -47,6 +47,15 @@ - "--password {{ amq_broker_instance_password }}" when: not amq_broker_instance_anonymous +- name: Disable security + ansible.builtin.set_fact: + amq_broker_options: + - "{{ amq_broker_options | join(' ') }}" + - "--allow-anonymous" + - "--user {{ amq_broker_instance_username }}" + - "--password {{ amq_broker_instance_password }}" + when: amq_broker_instance_anonymous + - name: Set address broker accepts connections on ansible.builtin.set_fact: amq_broker_options: diff --git a/roles/amq_broker/tasks/systemd.yml b/roles/amq_broker/tasks/systemd.yml index aed1435d..73b31363 100644 --- a/roles/amq_broker/tasks/systemd.yml +++ b/roles/amq_broker/tasks/systemd.yml @@ -70,6 +70,32 @@ notify: - restart amq_broker +- name: "Configure prometheus metrics" + become: yes + when: amq_broker_prometheus_enabled + block: + - name: Ensure lib is available to instance + ansible.builtin.copy: + src: "{{ amq_broker.home }}/lib/artemis-prometheus-metrics-plugin-1.1.0.redhat-00002.jar" + dest: "{{ amq_broker.instance_home }}/lib/" + remote_src: yes + owner: "{{ amq_broker_service_user }}" + group: "{{ amq_broker_service_group }}" + mode: 0644 + notify: + - restart amq_broker + - name: Configure metrics plugin + xml: + path: "{{ amq_broker.instance_home }}/etc/broker.xml" + xpath: /conf:configuration/core:core/core:metrics/core:plugin + attribute: class-name + value: org.apache.activemq.artemis.core.server.metrics.plugins.ArtemisPrometheusMetricsPlugin + namespaces: + conf: urn:activemq + core: urn:activemq:core + notify: + - restart amq_broker + - name: Reload systemd become: yes ansible.builtin.systemd: # noqa no-handler definitely not a candidate for a handler, because of start/flush below