From 1666766223334cf06b639b0f889a90d069a3c614 Mon Sep 17 00:00:00 2001 From: Steven Joseph Date: Tue, 21 Nov 2017 21:59:09 +1100 Subject: [PATCH] Add rabbitmq exporter support --- prometheus/exporter/rabbitmq.sls | 49 +++++++++++++++++++ prometheus/files/default-rabbitmq.jinja | 20 ++++++++ .../files/rabbitmq_exporter.systemd.jinja | 18 +++++++ 3 files changed, 87 insertions(+) create mode 100644 prometheus/exporter/rabbitmq.sls create mode 100644 prometheus/files/default-rabbitmq.jinja create mode 100644 prometheus/files/rabbitmq_exporter.systemd.jinja diff --git a/prometheus/exporter/rabbitmq.sls b/prometheus/exporter/rabbitmq.sls new file mode 100644 index 0000000..738244d --- /dev/null +++ b/prometheus/exporter/rabbitmq.sls @@ -0,0 +1,49 @@ +{% from "prometheus/map.jinja" import prometheus with context %} + +include: + - prometheus.user + +rabbitmq_exporter_tarball: + archive.extracted: + - name: {{ prometheus.exporter.rabbitmq.install_dir }} + - source: {{ prometheus.exporter.rabbitmq.source }} + - source_hash: {{ prometheus.exporter.rabbitmq.source_hash }} + - user: {{ prometheus.user }} + - group: {{ prometheus.group }} + - archive_format: tar + - if_missing: {{ prometheus.exporter.rabbitmq.version_path }} + +rabbitmq_exporter_bin_link: + file.symlink: + - name: /usr/bin/rabbitmq_exporter + - target: {{ prometheus.exporter.rabbitmq.version_path }}/rabbitmq_exporter + - require: + - archive: rabbitmq_exporter_tarball + +rabbitmq_exporter_defaults: + file.managed: + - name: /etc/default/rabbitmq_exporter + - source: salt://prometheus/files/default-rabbitmq_exporter.jinja + - template: jinja + +rabbitmq_exporter_service_unit: + file.managed: +{%- if grains.get('init') == 'systemd' %} + - name: /etc/systemd/system/rabbitmq_exporter.service + - source: salt://prometheus/files/rabbitmq_exporter.systemd.jinja +{%- elif grains.get('init') == 'upstart' %} + - name: /etc/init/rabbitmq_exporter.conf + - source: salt://prometheus/files/rabbitmq_exporter.upstart.jinja +{%- endif %} + - require_in: + - file: rabbitmq_exporter_service + +rabbitmq_exporter_service: + service.running: + - name: rabbitmq_exporter + - enable: True + - reload: True + - watch: + - file: rabbitmq_exporter_service_unit + - file: rabbitmq_exporter_defaults + - file: rabbitmq_exporter_bin_link diff --git a/prometheus/files/default-rabbitmq.jinja b/prometheus/files/default-rabbitmq.jinja new file mode 100644 index 0000000..b93cdcc --- /dev/null +++ b/prometheus/files/default-rabbitmq.jinja @@ -0,0 +1,20 @@ +#https://github.com/kbudde/rabbitmq_exporter +RABBIT_CAPABILITIES=no_sort,bert + + +#Environment variable|default|description +#--------------------|-------|------------ +#RABBIT_URL | | url to rabbitMQ management plugin +#RABBIT_USER | guest | username for rabbitMQ management plugin +#RABBIT_PASSWORD | guest | password for rabbitMQ management plugin +#RABBIT_USER_FILE| | location of file with username (useful for docker secrets) +#RABBIT_PASSWORD_FILE | | location of file with password (useful for docker secrets) +#PUBLISH_PORT | 9090 | Listening port for the exporter +#OUTPUT_FORMAT | TTY | Log ouput format. TTY and JSON are suported +#LOG_LEVEL | info | log level. possible values: "debug", "info", "warning", "error", "fatal", or "panic" +#CAFILE | ca.pem | path to root certificate for access management plugin. Just needed if self signed certificate is used. Will be ignored if the file does not exist +#SKIPVERIFY | false | true/0 will ignore certificate errors of the management plugin +#INCLUDE_QUEUES | .* | reqgex queue filter. just matching names are exported +#SKIP_QUEUES | ^$ |regex, matching queue names are not exported (useful for short-lived rpc queues). First performed INCLUDE, after SKIP +#RABBIT_CAPABILITIES | | comma-separated list of extended scraping capabilities supported by the target RabbitMQ server +#RABBIT_EXPORTERS | exchange,node,overview,queue | List of enabled modules. Just "connections" is not enabled by default diff --git a/prometheus/files/rabbitmq_exporter.systemd.jinja b/prometheus/files/rabbitmq_exporter.systemd.jinja new file mode 100644 index 0000000..07966c7 --- /dev/null +++ b/prometheus/files/rabbitmq_exporter.systemd.jinja @@ -0,0 +1,18 @@ +[Unit] +Description=Prometheus rabbitmq exporter +Documentation=https://github.com/kbudde/rabbitmq_exporter +Wants=basic.target +After=basic.target network.target + +[Service] +User=prometheus +Group=prometheus +EnvironmentFile=/etc/default/rabbitmq_exporter +ExecStart=/usr/bin/rabbitmq_exporter +ExecReload=/bin/kill -HUP $MAINPID +KillMode=process +Restart=always +RestartSec=42s + +[Install] +WantedBy=multi-user.target