Prometheus 监控 Rabbitmq

这里只是对prometheus监控MySQL的配置过程做个记录,方便以后查阅。

1.下载rabbitmq_exporter

github地址:https://github.com/kbudde/rabbitmq_exporter/releases

1
2
3
4
[root@node1 prometheus]# wget https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0.0-RC7/rabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz
[root@node1 prometheus]# tar xf rabbitmq_exporter-1.0.0-RC7.linux-amd64.tar.gz
[root@node1 prometheus]# mv -f rabbitmq_exporter-1.0.0-RC7.linux-amd64/ rabbitmq_exporter
[root@node1 prometheus]# cd rabbitmq_exporter

2.修改连接rabbitmq的配置文件

如果没有配置文件可以去github下载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@node1 prometheus]# cat config.json

{
"rabbit_url": "http://127.0.0.1:15672",
"rabbit_user": "admin",
"rabbit_pass": "admin",
"publish_port": "9419",
"publish_addr": "",
"output_format": "JSON",
"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
}

主要修改以下配置:

rabbit_url:rabbitmq地址;
rabbit_user:mq的登录账户;
rabbit_pass:mq的账户密码;
publish_port:暴露监控指标的端口;
publish_addr:监控本机端口;

3.配置rabbitmq_exporter服务启动

添加到系统启动

1
2
3
4
5
6
7
8
9
10
11
12
[root@node1 rabbitmq_exporter]# cat /usr/lib/systemd/system/rabbitmq_exporter.service
[Service]
User=root
Group=root
ExecStart=/data/prometheus/rabbitmq_exporter/rabbitmq_exporter -config-file /data/prometheus/rabbitmq_exporter/config.json

[Install]
WantedBy=multi-user.target

[Unit]
Description=node_exporter
After=network.target

启动rabbitmq_exporter

1
2
3
[root@node1 rabbitmq_exporter]# systemctl enable rabbitmq_exporter 
[root@node1 rabbitmq_exporter]# systemctl start rabbitmq_exporter
[root@node1 rabbitmq_exporter]# systemctl status rabbitmq_exporter

4.修改prometheus配置

1
2
3
4
5
6
7
8
9
10
11
scrape_configs:
- job_name: 'tst_wx1_108'
scrape_interval: 5s
scrape_timeout: 4s
static_configs:
- targets: ['172.20.190.108:9090','172.20.190.108:9100']
labels: {cluster: 'tst',type: 'basic',env: 'tst',job: 'tst_wx1_108',export: 'prometheus'}
- targets: ['172.20.190.108:9256']
labels: {cluster: 'tst',type: 'process',env: 'tst',job: 'tst_wx1_108',export: 'process_exporter'}
- targets: ['172.20.190.108:9419']
labels: {cluster: 'tst',type: 'middle',env: 'tst',job: 'tst_wx1_108',export: 'rabbitmq_exporter'}

5.重启prometheus

如果开启了api管理功能,可以如下方式热加载配置

1
curl -X POST http://127.0.0.1:9090/-/reload

6.grafana出图

推荐使用4371

效果如下

图片1

-------------本文结束感谢您的阅读-------------