使用Prometheus和Grafana监控RabbitMQ集群 (使用RabbitMQ自带插件)
配置RabbitMQ集群
官方文档:https://www.rabbitmq.com/prometheus.html#quick-start
官方github地址:https://github.com/rabbitmq/rabbitmq-server
# 获取集群名称
rabbitmq-diagnostics -q cluster_status
# 设置集群名称
rabbitmqctl -q set_cluster_name myrabbitmq
# 启用插件
rabbitmq-plugins enable rabbitmq_prometheus
# 启用插件后的效果显示
rabbitmq-plugins enable rabbitmq_prometheus
Enabling plugins on node rabbit@ed9618ea17c9:
rabbitmq_prometheus
The following plugins have been configured:
rabbitmq_management_agent
rabbitmq_prometheus
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@ed9618ea17c9...
The following plugins have been enabled:
rabbitmq_management_agent
rabbitmq_prometheus
rabbitmq_web_dispatch
started 3 plugins.
# 验证插件启用后的效果
curl -s localhost:15692/metrics | head -n 3 # 有密码的形式 curl -u username:password -s localhost:15692/metrics | head -n 3 (rabbitmq密码是访问15672使用的,访问15692不用密码)
# TYPE erlang_mnesia_held_locks gauge
# HELP erlang_mnesia_held_locks Number of held locks.
erlang_mnesia_held_locks{node="rabbit@65f1a10aaffa",cluster="rabbit@65f1a10aaffa"} 0
RabbitMQ 在专用 TCP 端口(默认为15692)上公开指标。
因此rabbitmq集群需要开放15692端口才行
配置prometheus
- job_name: 'rabbitmq'
static_configs:
- targets: ['172.16.0.207:15692','172.16.0.84:15692','172.16.0.7:15692']
配置 grafana dashboad
地址:
RabbitMQ-Overview
https://grafana.com/grafana/dashboards/10991
RabbitMQ-Quorum-Queues-Raft
https://grafana.com/grafana/dashboards/11340
RabbitMQ-Stream
https://grafana.com/grafana/dashboards/14798
面板ID:10991 => RabbitMQ-Overview
面板ID:11340 => RabbitMQ-Quorum-Queues-Raft
面板ID:14798 => RabbitMQ-Stream