參考官方文檔搭建 https://www.rabbitmq.com/prometheus.html
基于 centos7 環(huán)境,rabbitmq版本3.8
1 docker下 rabbitmq 安裝
docker pull rabbitmq
2 啟動 rabbitmq
docker run --name rabbitmq -p 5672:5672 -p 15692:15692 [rabbitmq image id]
15692端口一定要映射 因?yàn)檫@是 rabbitmq 提供的監(jiān)控端點(diǎn)端口
3 啟動 rabbitmq_prometheus 插件
rabbitmq3.8本身已經(jīng)自帶了prometheus的插件,直接開啟即可
首先進(jìn)入 rabbitmq 容器中
docker exec -it [rabbitmq container id] bin/sh
修改一下 rabbitmq cluster name
rabbitmqctl -q set_cluster_name testing-prometheus
啟動 rabbitmq_prometheus 插件 3.8已經(jīng)自帶 開通即可
rabbitmq-plugins enable rabbitmq_prometheus
出現(xiàn)以下相似的提示就是成功
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...
訪問 localhost:15692/metrics 有一大串的文本提示就代表成功
7.PNG
1 prometheus 安裝
文檔 https://prometheus.io/docs/introduction/first_steps/
下載 https://prometheus.io/download/
下載對應(yīng)系統(tǒng)版本并解壓
tar xvfz prometheus-*.tar.gz
cd prometheus-*
prometheus 的配置都是基于 prometheus.yml 這個文件
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
# - "first.rules"
# - "second.rules"
scrape_configs:
- job_name: testing-prometheus #這里修改成 rabbitmq cluster-name 非強(qiáng)制-只是為了好區(qū)分
static_configs:
- targets: ['localhost:15692'] # 這里一定要修改成 rabbitmq 的部署路徑 加監(jiān)控端口 多個請參考文檔配置
啟動
./prometheus --config.file=prometheus.yml
訪問頁面 http://localhost: 9090 ,點(diǎn)擊 Targets 看到 rabbitmq 就代表 成功
image.png
Grafana 安裝
官網(wǎng)文檔 https://grafana.com/docs/grafana/latest/
安裝文檔 https://grafana.com/grafana/download
Red Hat, CentOS, RHEL, and Fedora(64 Bit)
wget [https://dl.grafana.com/oss/release/grafana-7.1.5-1.x86_64.rpm](https://dl.grafana.com/oss/release/grafana-7.1.5-1.x86_64.rpm)
sudo yum install grafana-7.1.5-1.x86_64.rpm
啟動服務(wù)
sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl status grafana-server
訪問 localhost:3000 賬號/密碼 admin/admin
之后看圖配置即可
image.png
1.PNG
2.PNG
image.png
接下來是配置 rabbitmq 相當(dāng)簡單
1下載 rabbitmq 的 json 文件
下載鏈接 https://grafana.com/grafana/dashboards/10991
2導(dǎo)入json文件
3.PNG
4.PNG
5.PNG
6.PNG
到這里就大功告成了懦砂!