企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 一、软件环境介绍 &nbsp;&nbsp;&nbsp;1.1主机清单 职责 | ip地址 | 备注 Prometheus服务器 | 192.168.100.85 | docker机式的prometheus 待监控Linux | 192.168.100.141 | 待准备组件: rabbitmq:3.7.15-management <hr> ## 二、prometheus监控rabbitmq ### &nbsp;&nbsp;&nbsp;2.1 docker安装(略) ### &nbsp;&nbsp;&nbsp;2.2 docker-compose安装(略) ### &nbsp;&nbsp;&nbsp;2.3 安装rabbitmq &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;创建rabbitmq目录 mkdir /data/rabbitmq -p cd /data/rabbitmq &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;创建docker-compose.yaml vim docker-compose.yaml &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;配置如下: services: mysql: image: rabbitmq:3.7.15-management container_name: rabbitmq restart: always volumes: - /data/rabbitmq/data:/var/lib/rabbitmq - /data/rabbitmq/log:/var/log/rabbitmq ports: - 5672:5672 - 15672:15672 &nbsp;&nbsp;&nbsp;启动 docker-compose.yaml docker-compose up -d &nbsp;&nbsp;&nbsp;查看docker的信息 docker images docker ps -a <hr> ## &nbsp;&nbsp;&nbsp;2.4 rabbitmq开启监控 ## &nbsp;&nbsp;&nbsp;2.5 安装rabbitmq_exporter &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;centos2机器上,编辑docker-compose.yaml文件 vi docker-compose.yaml &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如图所示:加入一个mysqld_exporter配置 ![](https://img.kancloud.cn/c8/59/c8596be4c1038e8e9f0e42322d697bdb_781x427.png) rabbitmq-exporter: image: registry.cn-hangzhou.aliyuncs.com/ldw520/rabbitmq-exporter:latest container_name: rabbitmq_exporter restart: always environment: RABBIT_URL: "http://192.168.100.141:15672" RABBIT_USER: "guest" REDIS_PASSWORD: "guest" PUBLISH_PORT: "9419" OUTPUT_FORMAT: "JSON" ports: - "9419:9419" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;运行docker-compose up-d的命令,观察rabbitmq-exporter的程序是否成功运行 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;宿主机上访问rabbitmq的metrics http://192.168.100.141:9419/metrics <hr> ## &nbsp;&nbsp;&nbsp;2.6 prometheus服务器添加rabbitmq_exporter的地址 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;192.168.100.85的centos上,修改prometheus的配置文件 #进入docker-prometheus目录 cd /data/docker-prometheus #修改prometheus.yml vi prometheus/prometheus.yml &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;添加monogodb_exporter配置如下图: ![](https://img.kancloud.cn/92/a7/92a78b9a937e5b3cc603058030306a05_570x290.png) - job_name: "rabbitmq-exporter" static_configs: - targets: ["192.168.100.141:9419"] labels: istance: "centos2服务器rabbitmq监听" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;保存后输入命令更新: curl -XPOST http://localhost:9090/-/reload &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;成功监听 ![](https://img.kancloud.cn/cc/8c/cc8c87cb7fc04e7cb0b58109b77be82c_1360x856.png) <hr/> ## &nbsp;&nbsp;&nbsp;2.6 rabbitmq服务器指标查询 rabbitmq_node_disk_free_himit #使用磁盘大小 rabbitmq_node_disk_free #磁盘总大小 rabbitmq_node_mem_used # 使用内存大小 rabbitmq_node_mem_limit #内存总大小 rabbitmg sockets_used #使用的sockets的数量 rabbitmg_sockets_available # 可用的sockets总数量 rabbitmq_fd_used #使用文件描述符的数量 rabbitmq fd_available #可用的文件描迷符总数量 <hr> &nbsp;&nbsp;&nbsp;2.6 grafana中对rabbitmq进行监控 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy id to clipboard->grafana的dashboards中lmport dashboard https://grafana.com/grafana/dashboards/4279-rabbitmq-monitoring/ ![](https://img.kancloud.cn/a5/47/a54741c2b896840bd700c6df85a08a1a_1605x976.png) ![](https://img.kancloud.cn/b8/7a/b87a291ee68c08bd8a183c603b374179_1917x893.png)