【prometheus使用系列】Prometheus监控rabbitmq3.8.0

背景

官方介绍

链接: https://www.rabbitmq.com/prometheus.html#overview-prometheus

As of 3.8.0, RabbitMQ ships with built-in Prometheus & Grafana support.
Support for Prometheus metric collector ships in the rabbitmq_prometheus plugin. The plugin exposes all RabbitMQ metrics on a dedicated TCP port, in Prometheus text format.
These metrics provide a deep insights into the state of RabbitMQ nodes and the runtime. They make reasoning about the behaviour of RabbitMQ, applications that use it and various infrastructure elements a lot more informed.

版本依赖

安装过程

安装erlang

vim /etc/yum.repos.d/rabbitmq-erlang.repo

[rabbitmq-erlang]
name=rabbitmq-erlang
baseurl=https://dl.bintray.com/rabbitmq-erlang/rpm/erlang/22/el/7
gpgcheck=1
gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
repo_gpgcheck=0
enabled=1

输入 命令,安装erlang。

rpm -import https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
yum install erlang
yum install rabbitmq-server

安装rabbitmq-server

vim /etc/yum.repos.d/rabbitmq.repo

[bintray-rabbitmq-server]
name=bintray-rabbitmq-rpm
baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.8.x/el/7/
gpgcheck=0
repo_gpgcheck=0
enabled=1

修改配置,并授权

vim /etc/rabbitmq/rabbitmq.conf

#log.dir = /data/rabbitmq/log
log.file = rabbit.log

log.file.rotation.date=$D0
log.file.rotation.size=0

vim /etc/rabbitmq/rabbitmq-env.conf

RABBITMQ_MNESIA_BASE=/data/rabbitmq/mnesia
RABBITMQ_LOG_BASE=/data/rabbitmq/log

授权给rabbitmq用户。

chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/
mkdir -p data/rabbitmq/log
mkdir -p /data/rabbitmq/mnesia
chown -R rabbitmq:rabbitmq /data/rabbitmq/

启动服务,并启动插件

1.启动rabbitmq-server服务

systemctl start rabbitmq-server
systemctl status rabbitmq-server

2.启动management插件。

rabbitmq-plugins enable rabbitmq_management

3.admin用户授权

rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl status

4.查看插件
输入命令:

rabbitmq-plugins list

5.启动rabbitmq_prometheus插件

rabbitmq-plugins enable rabbitmq_prometheus

效果

命令行输入rabbitmqctl status

浏览器访问