kube-prometheus 监控 rocketmq etcd服务
目前k8s 升级到 1.18版本, rocketmq etcd 部署在外部, 由于使用了kube-prometheus 对k8s进行了监控,所以打算直接抓取rocketmq ,
可以从prometheus 官网找到合适 exporter https://prometheus.io/docs/instrumenting/exporters/
结构:
k8s1.18 master 172.16.230.22 - 24 etcd
node 172.16.230.25 - 28
rocketmq 172.16.230.153
1. 首先现在rocketmq-exporter
git clone https://github.com/apache/rocketmq-exporter
2. 编译,启动
mvn clean install java -jar rocketmq-exporter-0.0.1-SNAPSHOT.jar
打开地址: http://172.16.230.153:5557/metrics
3. 监控指标:
4. 告警指标
5. kube-prometheus 添加 prometheus-servicemonitor
[root@master1 manifests]# cat prometheus-serviceMonitorrocketmq.yaml apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: exporter-rocketmq namespace: monitoring labels: app: exporter-rocketmq spec: jobLabel: exporter-rocketmq endpoints: - port: port interval: 30s scheme: http selector: matchLabels: app: exporter-rocketmq namespaceSelector: matchNames: - kube-system
6. kube-prometheus 添加 rocketmsq service和 endpoint ,把rocketmq服务导入到集群
[root@master1 manifests]# cat rocketmq-service-endpoint.yaml apiVersion: v1 kind: Endpoints metadata: name: exporter-rocketmq namespace: kube-system labels: app: exporter-rocketmq subsets: - addresses: - ip: 172.16.230.153 ports: - name: port port: 5557 protocol: TCP --- apiVersion: v1 kind: Service metadata: name: exporter-rocketmq namespace: kube-system labels: app: exporter-rocketmq spec: type: ClusterIP clusterIP: None ports: - name: port port: 5557 protocol: TCP
7. 执行yaml
[root@master1 manifests]# kubectl create -f prometheus-serviceMonitorrocketmq.yaml -f rocketmq-service-endpoint.yaml
8. 查看显示
9. 查看kube-prometheus target 已经psql
[root@master1 manifests]# kubectl port-forward --address 0.0.0.0 pod/prometheus-k8s-0 -n monitoring 9090:9090
10. 显示
11. grafana 配置
参考: