K8S Prometheus-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中

 vi rocketmq-standalone-exporter-cm.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: rocketmq-standalone-exporter-cm
  namespace: develop
data:
  namesrvAddr: "--rocketmq.config.namesrvAddr=你的nameserver:9876"

创建configMap

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

部署exporter

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

vi deployment.yaml

 
apiVersion: v1
kind: Service
metadata:
  name: rocketmq-standalone-exporter-svc
  labels:
    app: rocketmq-standalone-exporter-svc
    app.kubernetes.io/component: metrics
    app.kubernetes.io/instance: rocketmq-standalone-exporter
  namespace: develop
spec:
  ports:
  - name: http-metrics
    port: 5557
    targetPort: 5557
  selector:
    app: rocketmq-standalone-exporter
    app.kubernetes.io/component: metrics
    app.kubernetes.io/instance: rocketmq-standalone-exporter
  type: ClusterIP

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rocketmq-standalone-exporter
  namespace: develop
spec:
  selector:
    matchLabels:
      app: rocketmq-standalone-exporter
      app.kubernetes.io/component: metrics
      app.kubernetes.io/instance: rocketmq-standalone-exporter
  replicas: 1
  revisionHistoryLimit: 10
  template:
    metadata:
      labels:
        app: rocketmq-standalone-exporter
        app.kubernetes.io/component: metrics
        app.kubernetes.io/instance: rocketmq-standalone-exporter
    spec:
      containers:
      - name: rocketmq-standalone-exporter
        env:
        - name: INTERVAL
          valueFrom:
            configMapKeyRef:
              name: rocketmq-standalone-exporter-cm
              key: namesrvAddr
        image: 你的仓库地址/sawyerlan/rocketmq-exporter:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 5557
          name: port
          protocol: TCP
        args: ["$(INTERVAL)"]
        ##args: ## 或者直接使用参数配置
        ##- --rocketmq.config.namesrvAddr=你的namesrvAddr:9876

开始部署 kubectl apply -f deployment.yaml

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

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

创建ServiceMonitor

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

vi serviceMonitor-rocketmq-standalone.yaml

 
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    jobLabel: rocketmq-standalone-exporter
  name: prometheus-prometheus-rocket-standalone-exporter
  namespace: develop
spec:
  endpoints:
  - interval: 60s
    port: http-metrics  # 端口名称
  jobLabel: jobLabel
  namespaceSelector: # 标签匹配 rocketmq standalone Service 所在的命名空间
    matchNames:
    - develop
  selector: # 标签匹配 rocketmq standalone Service
    matchLabels:
      app: rocketmq-standalone-exporter-svc
      app.kubernetes.io/component: metrics
      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

相关推荐
ether-lin2 小时前
DevOps实战:用Kubernetes和Argo打造自动化CI/CD流程(2)
kubernetes·自动化·devops
是芽芽哩!5 小时前
【Kubernetes 指南】基础入门——Kubernetes 基本概念(二)
云原生·容器·kubernetes
怡雪~7 小时前
k8s使用ceph
ceph·容器·kubernetes
运维小文8 小时前
K8S中的服务质量QOS
云原生·容器·kubernetes
华为云开发者联盟8 小时前
Karmada v1.12 版本发布!单集群应用迁移可维护性增强
云原生·kubernetes·开源·容器编排·karmada
Hadoop_Liang8 小时前
Kubernetes Secret的创建与使用
云原生·容器·kubernetes
元气满满的热码式8 小时前
K8S集群部署实战(超详细)
云原生·容器·kubernetes
上海运维Q先生10 小时前
面试题整理13----deployment和statefulset区别
运维·面试·kubernetes
dzend16 小时前
Kafka、RocketMQ、RabbitMQ 对比
kafka·rabbitmq·rocketmq
AKA小徐16 小时前
Debian12使用RKE2离线部署3master2node三主两从的k8s集群详细教程
kubernetes·rancher·rke2