From 4ada1a123584d902697c8b8ef74b422ada8f51db Mon Sep 17 00:00:00 2001 From: Deimos Date: Sun, 20 Jan 2019 15:10:31 -0700 Subject: [PATCH] Add RabbitMQ exporter for Prometheus --- .../prometheus_rabbitmq_exporter.service | 14 ++++++++++ .../exporters/rabbitmq_exporter.sls | 28 +++++++++++++++++++ salt/salt/prometheus/prometheus.yml | 4 +++ salt/salt/top.sls | 1 + 4 files changed, 47 insertions(+) create mode 100644 salt/salt/prometheus/exporters/prometheus_rabbitmq_exporter.service create mode 100644 salt/salt/prometheus/exporters/rabbitmq_exporter.sls diff --git a/salt/salt/prometheus/exporters/prometheus_rabbitmq_exporter.service b/salt/salt/prometheus/exporters/prometheus_rabbitmq_exporter.service new file mode 100644 index 0000000..5b70d76 --- /dev/null +++ b/salt/salt/prometheus/exporters/prometheus_rabbitmq_exporter.service @@ -0,0 +1,14 @@ +[Unit] +Description=Prometheus RabbitMQ Exporter +After=syslog.target network.target + +[Service] +Type=simple +RemainAfterExit=no +WorkingDirectory=/opt/prometheus_rabbitmq_exporter +User=prometheus +Group=prometheus +ExecStart=/opt/prometheus_rabbitmq_exporter/rabbitmq_exporter + +[Install] +WantedBy=multi-user.target diff --git a/salt/salt/prometheus/exporters/rabbitmq_exporter.sls b/salt/salt/prometheus/exporters/rabbitmq_exporter.sls new file mode 100644 index 0000000..2147293 --- /dev/null +++ b/salt/salt/prometheus/exporters/rabbitmq_exporter.sls @@ -0,0 +1,28 @@ +# Download/extract and set up the rabbitmq exporter +include: + - prometheus.user + +unpack-rabbitmq-exporter: + archive.extracted: + - name: /opt/prometheus_rabbitmq_exporter + - source: + - salt://prometheus/exporters/rabbitmq_exporter-1.0.0-WIP.linux-amd64.tar.gz + - https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0-wip1/rabbitmq_exporter-1.0.0-WIP.linux-amd64.tar.gz + - source_hash: sha256=d478dcf72d8a5175a4f3ea6b8e0356f64e2fcdb7b65bb5bfc0bd161d896abc4a + - if_missing: /opt/prometheus_rabbitmq_exporter + - user: prometheus + - group: prometheus + - options: --strip-components=1 + - enforce_toplevel: False + +/etc/systemd/system/prometheus_rabbitmq_exporter.service: + file.managed: + - source: salt://prometheus/exporters/prometheus_rabbitmq_exporter.service + - user: root + - group: root + - mode: 644 + +prometheus-rabbitmq-exporter-service: + service.running: + - name: prometheus_rabbitmq_exporter + - enable: True diff --git a/salt/salt/prometheus/prometheus.yml b/salt/salt/prometheus/prometheus.yml index 49c0bae..89c8d41 100644 --- a/salt/salt/prometheus/prometheus.yml +++ b/salt/salt/prometheus/prometheus.yml @@ -7,6 +7,10 @@ scrape_configs: static_configs: - targets: ['localhost:9100'] + - job_name: "rabbitmq" + static_configs: + - targets: ['localhost:9419'] + - job_name: "redis" static_configs: - targets: ['localhost:9121'] diff --git a/salt/salt/top.sls b/salt/salt/top.sls index 216ba3f..b829b43 100644 --- a/salt/salt/top.sls +++ b/salt/salt/top.sls @@ -15,6 +15,7 @@ base: - cmark-gfm - prometheus.exporters.node_exporter - prometheus.exporters.postgres_exporter + - prometheus.exporters.rabbitmq_exporter - prometheus.exporters.redis_exporter - consumers - site-icons-spriter