Prometheus 采集rabbitmq监控数据

Posted CIAS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Prometheus 采集rabbitmq监控数据相关的知识,希望对你有一定的参考价值。

 

Prometheus采集主机监控参考部署下载,图形生成

系统exporter 安装参考Grafana download
Windows参考图形生成参考win_exporter
Linux参考node_exporter
mysql参考Mysql_exporter
SQL Server参考SQL exporter
Redis 参考Redis_exporter
cadvisor参考cadvisor
rabbitmq参考参考rabbitmq

snmp_exporter

参考图形展示在测试中

snmp_exporter

zabbix集成参考

 

download  rabbitmq_exporter

rabbitmq_exporter 一键监控安装脚本 

  • 采集端口默认端口9419

16-41 行说明

Environmentvariabledefault description
RABBIT_URLhttp://127.0.0.1:15672url to rabbitMQ management plugin (must start with http(s)😕/)
RABBIT_USERguestusername for rabbitMQ management plugin. User needs monitoring tag!
RABBIT_PASSWORDguestpassword for rabbitMQ management plugin
RABBIT_USER_FILElocation of file with username (useful for docker secrets)
RABBIT_PASSWORD_FILElocation of file with password (useful for docker secrets)
PUBLISH_PORT9419Listening port for the exporter
PUBLISH_ADDR“”Listening host/IP for the exporter
OUTPUT_FORMATTTYLog ouput format. TTY and JSON are suported
LOG_LEVELinfolog level. possible values: “debug”, “info”, “warning”, “error”, “fatal”, or “panic”
CAFILEca.pempath to root certificate for access management plugin. Just needed if self signed certificate is used. Will be ignored if the file does not exist
CERTFILEclient-cert.pempath to client certificate used to verify the exporter’s authenticity. Will be ignored if the file does not exist
KEYFILEclient-key.pempath to private key used with certificate to verify the exporter’s authenticity. Will be ignored if the file does not exist
SKIPVERIFYfalsetrue/0 will ignore certificate errors of the management plugin
SKIP_VHOST^$regex, matching vhost names are not exported. First performs INCLUDE_VHOST, then SKIP_VHOST
INCLUDE_VHOST.*regex vhost filter. Only queues in matching vhosts are exported
INCLUDE_QUEUES.*regex 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_CAPABILITIESbert,no_sortcomma-separated list of extended scraping capabilities supported by the target RabbitMQ server
RABBIT_EXPORTERSexchange,node,queueList of enabled modules. Possible modules: connections,shovel,federation,exchange,node,queue,memory
RABBIT_TIMEOUT30timeout in seconds for retrieving data from management plugin.
MAX_QUEUES0max number of queues before we drop metrics (disabled if set to 0)
EXCLUDE_METRICS
  • Metric names to exclude from export. comma-seperated. e.g. “recv_oct, recv_cnt”. See exporter_*.go for names
vim /rabbitmq_exporter.sh
#!/bin/sh
# -*- coding: utf-8 -*-
# Date: 2022/11/29

echo "download rabbitmq_exporter"
sleep 2
wget -N -P /root/ https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0.0-RC19/rabbitmq_exporter_1.0.0-RC19_linux_amd64.tar.gz

echo "Unzip rabbitmq_exporter"
sleep 2
mkdir -p /usr/local/rabbitmq_exporter
tar -zxf /root/rabbitmq_exporter_1.0.0-RC19_linux_amd64.tar.gz -C /usr/local/rabbitmq_exporter

echo "add config.json"
sleep 2
cat >>/usr/local/rabbitmq_exporter/config.json << EOF

    "rabbit_url": "http://127.0.0.1:15672",
    "rabbit_user": "admin",
    "rabbit_pass": "admin@123",
    "publish_port": "9419",
    "publish_addr": "",
    "output_format": "TTY",
    "ca_file": "ca.pem",
    "cert_file": "client-cert.pem",
    "key_file": "client-key.pem",
    "insecure_skip_verify": false,
    "exlude_metrics": [],
    "include_queues": ".*",
    "skip_queues": "^$",
    "skip_vhost": "^$",
    "include_vhost": ".*",
    "rabbit_capabilities": "no_sort,bert",
    "enabled_exporters": [
            "exchange",
            "node",
            "overview",
            "queue"
    ],
    "timeout": 30,
    "max_queues": 0

EOF

echo "rabbitmq_exporter Creating a Service Script"
sleep 2
cat >>/usr/lib/systemd/system/rabbitmq_exporter.service<< EOF
[Unit]
Description=rabbitmq_exporter
Documentation=https://github.com/kbudde/rabbitmq_exporter/releases
After=network.target

[Service]
Type=simple
User=root
Group=root

ExecStart=/usr/local/rabbitmq_exporter/rabbitmq_exporter \\
-config-file=/usr/local/rabbitmq_exporter/config.json
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

echo "rabbitmq_exporter Example Set the automatic startup service"
sleep 2
systemctl daemon-reload && systemctl enable --now rabbitmq_exporter
rm -rf /root/rabbitmq_exporter_1.0.0-RC19_linux_amd64.tar.gz

执行安装

sh /rabbitmq_exporter.sh

数据采集结果 

Prometheus代码设置

  - job_name: 'Rabbitmq'
    scrape_interval: 5s
    static_configs:
      - targets:
        - 192.168.11.230:9419
        labels:
          instance: RabbitMQ-192.168.11.230

Grafana 图形展示

单机图形展示 

以上是关于Prometheus 采集rabbitmq监控数据的主要内容,如果未能解决你的问题,请参考以下文章

Prometheus 采集rabbitmq监控数据

Prometheus 采集Windows主机监控数据

Prometheus 采集snmp监控数据

Prometheus 采集Mysql监控数据

Prometheus 采集redis监控数据

Prometheus 采集Windows主机监控数据