Skip to content

Commit

Permalink
Add prometheus metrics export plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
guidograzioli committed Jun 23, 2022
1 parent b5567f4 commit 0fa8299
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
4 changes: 4 additions & 0 deletions roles/amq_broker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion roles/amq_broker/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions roles/amq_broker/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 9 additions & 0 deletions roles/amq_broker/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 26 additions & 0 deletions roles/amq_broker/tasks/systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0fa8299

Please sign in to comment.