启用一个rabbitmq docker 服务
cat >docker-compose.yaml<<'EOF'
version: '3'
services:
rabbitmq:
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
EOF
rabbitmq-exporter 启动
- 直接docker
docker run -d -p 9419:9419 --name rabbitmq_exporter \
-e RABBIT_URL=http://10.19.1.220:15672 \
-e RABBIT_USER=guest \
-e RABBIT_PASSWORD=guest \
kbudde/rabbitmq-exporter
- docker-compose 方式
cd /data/rabbitmq/
cat >docker-compose.yml << 'EOF'
version: '3.3'
services:
rabbitmq_exporter:
image: kbudde/rabbitmq-exporter
container_name: rabbitmq_exporter
restart: always
environment:
RABBIT_URL: "http://10.19.1.220:15672"
RABBIT_USER: "guest"
RABBIT_PASSWORD: "guest"
PUBLISH_PORT: "9419"
OUTPUT_FORMAT: "JSON"
ports:
- "9419:9419"
EOF
check
docker-compose up -d
docker ps
docker logs -f rabbitmq_exporter
http://10.19.1.220:9419/metrics
Prometheus.yml 增加配置
cat >>prometheus/prometheus.yml << 'EOF'
- job_name: 'rabbitmq_exporter'
scrape_interval: 30s
static_configs:
- targets: ['10.19.1.220:9419']
labels:
instance: rabbitmq服务器
EOF
docker exec -it prometheus promtool check config /etc/prometheus/prometheus.yml
curl -X POST http://localhost:9090/-/reload
监控指标
rabbitmq_queues
rabbitmq_node_disk_free_limit
rabbitmq_node_disk_free
rabbitmq_node_mem_used
rabbitmq_node_mem_limit
rabbitmq_sockets_used
rabbitmq_sockets_available
rabbitmq_fd_used
rabbitmq_fd_available
Rabbitmq触发器
cat >> prometheus/rules/rabbitmq.yml << 'EOF'
groups:
- name: Rabbitmq
rules:
- alert: RabbitmqDown
expr: rabbitmq_up != 1
labels:
severity: High
annotations:
summary: "Rabbitmq Down,实例:{{ $labels.instance }}"
description: "Rabbitmq_exporter 连不上 Rabbitmq!!!!"
- alert: Rabbitmq有未确认消息
expr: rabbitmq_queue_messages_unacknowledged_global > 0
for: 1m
labels:
severity: critital
annotations:
summary: "Rabbitmq有未确认消息,实例:{{ $labels.instance }}"
description: "Rabbitmq有未确认消息>0,当前值: {{ $value }}"
EOF
热加载
docker exec -it prometheus promtool check config /etc/prometheus/prometheus.yml
curl -X POST http://localhost:9090/-/reload
添加dashboard
https://grafana.com/grafana/dashboards/10991-rabbitmq-overview
本文转载自: https://blog.csdn.net/zuopiezia/article/details/135314742
版权归原作者 石兴稳 所有, 如有侵权,请联系我们删除。
版权归原作者 石兴稳 所有, 如有侵权,请联系我们删除。