当前位置:   article > 正文

K8S Prometheus-rocketmq-exporter配置_k8s部署rocketmq-exporter

k8s部署rocketmq-exporter

下载rocketmq-exporter

通过Docker仓库下载

docker pull sawyerlan/rocketmq-exporter:latest

然后打标签,推送到自己的仓库

也可通过代码自己build镜像

git clone GitHub - apache/rocketmq-exporter: Apache RocketMQ Prometheus Exporter

然后打标签,推送到自己的仓库

准备configMap

部署export前需要有一个可用的rocketmq环境,需要提前将rocketmq的namesrvAddr准备好

将namesrvAddr存入configMap中

  1. vi rocketmq-standalone-exporter-cm.yaml
  2. apiVersion: v1
  3. kind: ConfigMap
  4. metadata:
  5. name: rocketmq-standalone-exporter-cm
  6. namespace: develop
  7. data:
  8. namesrvAddr: "--rocketmq.config.namesrvAddr=你的nameserver:9876"

创建configMap

kubectl apply -f rocketmq-standalone-exporter-cm.yaml

部署exporter

编写service和pod部署文件,使用上面configMap中的namesrvAddr

  1. vi deployment.yaml
  2. apiVersion: v1
  3. kind: Service
  4. metadata:
  5. name: rocketmq-standalone-exporter-svc
  6. labels:
  7. app: rocketmq-standalone-exporter-svc
  8. app.kubernetes.io/component: metrics
  9. app.kubernetes.io/instance: rocketmq-standalone-exporter
  10. namespace: develop
  11. spec:
  12. ports:
  13. - name: http-metrics
  14. port: 5557
  15. targetPort: 5557
  16. selector:
  17. app: rocketmq-standalone-exporter
  18. app.kubernetes.io/component: metrics
  19. app.kubernetes.io/instance: rocketmq-standalone-exporter
  20. type: ClusterIP
  21. ---
  22. apiVersion: apps/v1
  23. kind: Deployment
  24. metadata:
  25. name: rocketmq-standalone-exporter
  26. namespace: develop
  27. spec:
  28. selector:
  29. matchLabels:
  30. app: rocketmq-standalone-exporter
  31. app.kubernetes.io/component: metrics
  32. app.kubernetes.io/instance: rocketmq-standalone-exporter
  33. replicas: 1
  34. revisionHistoryLimit: 10
  35. template:
  36. metadata:
  37. labels:
  38. app: rocketmq-standalone-exporter
  39. app.kubernetes.io/component: metrics
  40. app.kubernetes.io/instance: rocketmq-standalone-exporter
  41. spec:
  42. containers:
  43. - name: rocketmq-standalone-exporter
  44. env:
  45. - name: INTERVAL
  46. valueFrom:
  47. configMapKeyRef:
  48. name: rocketmq-standalone-exporter-cm
  49. key: namesrvAddr
  50. image: 你的仓库地址/sawyerlan/rocketmq-exporter:latest
  51. imagePullPolicy: Always
  52. ports:
  53. - containerPort: 5557
  54. name: port
  55. protocol: TCP
  56. args: ["$(INTERVAL)"]
  57. ##args: ## 或者直接使用参数配置
  58. ##- --rocketmq.config.namesrvAddr=你的namesrvAddr:9876

开始部署 kubectl apply -f deployment.yaml

检查 pod的log日志是否有异常

curl 查看你的svc:5557/metric能否获取指标数据

创建ServiceMonitor

定时将指标数据存入到prometheus中

  1. vi serviceMonitor-rocketmq-standalone.yaml
  2. apiVersion: monitoring.coreos.com/v1
  3. kind: ServiceMonitor
  4. metadata:
  5. labels:
  6. jobLabel: rocketmq-standalone-exporter
  7. name: prometheus-prometheus-rocket-standalone-exporter
  8. namespace: develop
  9. spec:
  10. endpoints:
  11. - interval: 60s
  12. port: http-metrics # 端口名称
  13. jobLabel: jobLabel
  14. namespaceSelector: # 标签匹配 rocketmq standalone Service 所在的命名空间
  15. matchNames:
  16. - develop
  17. selector: # 标签匹配 rocketmq standalone Service
  18. matchLabels:
  19. app: rocketmq-standalone-exporter-svc
  20. app.kubernetes.io/component: metrics
  21. app.kubernetes.io/instance: rocketmq-standalone-exporter

创建 kubectl apply -f serviceMonitor-rocketmq-standalone.yaml

验证

查看config是否生效,等会会自动刷到配置文件中

http://你的k8s地址:9090端口对应的3xxxx端口/config

最下面是否有

job_name: serviceMonitor/develop/prometheus-prometheus-rocket-standalone-exporter/0

待出现后,过会就去检查一下target

http://你的k8s地址:9090端口对应的3xxxx端口/targets

最下面是否有

serviceMonitor/develop/prometheus-prometheus-rocket-standalone-exporter/0 (1/1 up)

查看监控grafana

导入一个模板 14612 or 10477

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/181663
推荐阅读
相关标签
  

闽ICP备14008679号