prometheus监控rocketmq,rocketmq-exporter容器镜像可以参考https://github.com/apache/rocketmq-exporter,yaml部署文件
apiVersion: apps/v1 kind: Deployment metadata: name: rocketmq-exporter namespace: rocketmq spec: replicas: 1 selector: matchLabels: app: rocketmq-exporter template: metadata: labels: app: rocketmq-exporter spec: hostNetwork: true containers: - name: rocketmq-exporter image: opcache/rabbitmq:rocketmq-exporter ports: - containerPort: 5557 nodeSelector: type3: test3-node --- apiVersion: v1 kind: Service metadata: name: rocketmq-exporter namespace: rocketmq spec: selector: app: rocketmq-exporter type: NodePort ports: - name: http port: 5557 targetPort: 5557 protocol: TCP nodePort: 45557
kube-prometheus 添加 prometheus-servicemonitor
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 kube-prometheus 添加 rocketmsq service和 endpoint ,把rocketmq服务导入到集群 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.231.112 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
Grafana Dashboard的模板文件参考 https://grafana.com/grafana/dashboards/10477
完成!