根据clickhouse-exporter 编辑yaml监控clickhouse

1.查看yaml

[root@k8s-master01 clickhouse03]# cat clickhouse-exporter.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: clickhouse-exporter03 
  name: clickhouse-exporter03
  namespace: monitoring
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: clickhouse-exporter03 
  template:
    metadata:
      labels:
        k8s-app: clickhouse-exporter03 
    spec:
      containers:
      - args:
        - --scrape_uri=http://1XXXXXX:8123 # 对应 CLICKHOUSE 实例的地址信息
        env:
          - name: CLICKHOUSE_USER
            value: "root"                    # 对应 CLICKHOUSE的账号
          - name: CLICKHOUSE_PASSWORD
            value: "xxxxxxxx"                # 对应 CLICKHOUSE的密码
        image: f1yegor/clickhouse-exporter:latest 
        imagePullPolicy: IfNotPresent
        name: clickhouse-exporter
        ports:
        - containerPort: 9116
          name: metric-port  # 这个名称在配置抓取任务的时候需要

2.配置PodMonitor

[root@k8s-master01 clickhouse03]# cat clickhouse-PodMonitor.yaml 
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: clickhouse-exporter03  # 填写一个唯一名称
  namespace: monitoring  # namespace固定,不要修改
spec:
  podMetricsEndpoints:
  - interval: 30s
    port: metric-port    # 填写pod yaml中Prometheus Exporter对应的Port的Name
    path: /metrics  # 填写Prometheus Exporter对应的Path的值,不填默认/metrics
    relabelings:
    - action: replace
      sourceLabels: 
      - instance
      regex: (.*)
      targetLabel: instance
      replacement: 'crs-xxxxxx' # 调整成对应的 MySQL 实例 ID
    - action: replace
      sourceLabels: 
      - instance
      regex: (.*)
      targetLabel: ip
      replacement: '1.x.x.x' # 调整成对应的 MySQL 实例 IP
  namespaceSelector:   # 选择要监控pod所在的namespace
    matchNames:
    - monitoring
  selector:  # 填写要监控pod的Label值,以定位目标pod
    matchLabels:
      k8s-app: clickhouse-exporter03
posted @ 2022-11-24 17:21  等等马上就好  阅读(168)  评论(0编辑  收藏  举报