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

相关推荐
景天科技苑9 小时前
【云原生开发】K8S多集群资源管理平台架构设计
云原生·容器·kubernetes·k8s·云原生开发·k8s管理系统
wclass-zhengge10 小时前
K8S篇(基本介绍)
云原生·容器·kubernetes
颜淡慕潇10 小时前
【K8S问题系列 |1 】Kubernetes 中 NodePort 类型的 Service 无法访问【已解决】
后端·云原生·容器·kubernetes·问题解决
昌sit!18 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
A ?Charis20 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
北漂IT民工_程序员_ZG21 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes
2301_806131361 天前
Kubernetes的基本构建块和最小可调度单元pod-0
云原生·容器·kubernetes
逻辑与&&1 天前
[Prometheus学习笔记]从架构到案例,一站式教程
笔记·学习·prometheus
SilentCodeY1 天前
containerd配置私有仓库registry
容器·kubernetes·containerd·镜像·crictl
Walden-20201 天前
构建基于 DCGM-Exporter, Node exporter,PROMETHEUS 和 GRAFANA 构建算力监控系统
docker·容器·grafana·prometheus