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

相关推荐
MYBOYER10 小时前
Kafka、RabbitMQ、RocketMQ的区别
kafka·rabbitmq·rocketmq
Hfc.13 小时前
ubuntu20.04系统搭建k8s1.28集群-docker作为容器运行时
ubuntu·kubernetes
alden_ygq20 小时前
Kubernetes Horizontal Pod Autosscaler(HPA)核心机制解析
云原生·容器·kubernetes
格桑阿sir20 小时前
Kubernetes控制平面组件:Kubelet详解(三):CRI 容器运行时接口层
docker·kubernetes·containerd·kubelet·cri-o·容器运行时·cri
hwj运维之路1 天前
k8s监控方案实践(三):部署与配置Grafana可视化平台
云原生·kubernetes·grafana
和计算机搏斗的每一天1 天前
k8s之探针
云原生·容器·kubernetes
项目題供诗2 天前
黑马k8s(四)
云原生·容器·kubernetes
杰克逊的日记2 天前
大项目k8s集群有多大规模,多少节点,有多少pod
云原生·容器·kubernetes
小张童鞋。2 天前
k8s之k8s集群部署
云原生·容器·kubernetes
long_21452 天前
k8s中ingress-nginx介绍
kubernetes·ingress-nginx