云容器引擎 CCE-监控CCE Turbo集群容器网络扩展指标:通过Prometheus查看指标

时间:2024-05-31 08:37:37

通过Prometheus查看指标

  1. 创建一个示例监控任务,详情请参见下发监控任务

    apiVersion: crd.dolphin.io/v1
    kind: MonitorPolicy
    metadata:
      name: example-task            #监控任务名
      namespace: kube-system        #必填,namespace必须为kube-system
    spec:
      selector:                     #选填,配置dolphin插件监控的后端,形如labelSelector格式,默认将监控本节点所有容器
        matchLabels:
          app: nginx
        matchExpressions:
          - key: app
            operator: In
            values:
              - nginx
      podLabel: []               #选填,用户标签
      ip4Tx:                        #选填,ipv4发送报文数和发送字节数这两个指标的开关,默认不开
        enable: true
      ip4Rx:                        #选填,ipv4接收报文数和接收字节数这两个指标的开关,默认不开
        enable: true
      ip4TxInternet:                #选填,ipv4发送公网报文数和发送公网字节数这两个指标的开关,默认不开
        enable: true
      healthCheck:                  #选填,本地节点 Pod 健康检查任务中最近一次健康检查是否健康、健康检查总健康&不健康次数这三个指标开关,默认不开
        enable: true                # true false
        failureThreshold: 3         #选填,健康检查不健康判定失败次数,默认1次健康检查失败即判定不健康
        periodSeconds: 5            #选填,健康检查任务检查间隔时间,单位秒,默认60
        command: ""                 #选填,健康检查任务检查命令,支持:ping、arping、curl,默认 ping
        ipFamilies: [""]            #选填,健康检查IP地址族,支持:ipv4,默认ipv4
        port: 80                    #选填,使用curl时必选,端口号
        path: ""                    #选填,使用curl时必选,http api 路径
      monitor:
        ip:
          ipReceive:
            aggregateType: flow       #选填,支持填写"pod"或"flow",分别表示pod粒度监控或流粒度监控
          ipSend:
            aggregateType: flow       #选填,支持填写"pod"或"flow",分别表示pod粒度监控或流粒度监控
        tcp:
          tcpReceive:
            aggregateType: flow       #选填,支持填写"pod"或"flow",分别表示pod粒度监控或流粒度监控
          tcpSend:
            aggregateType: flow       #选填,支持填写"pod"或"flow",分别表示pod粒度监控或流粒度监控
          tcpRetrans:
            aggregateType: flow       #选填,支持填写"pod"或"flow",分别表示pod粒度监控或流粒度监控
          tcpRtt:
            aggregateType: flow       #选填,支持填写"flow",表示流粒度监控,单位:微秒
          tcpNewConnection:
            aggregateType: pod        #选填,支持填写"pod",表示pod粒度监控

  2. 为Prometheus创建一个公网LoadBalancer类型的Service,提供公网访问。

    apiVersion: v1
    kind: Service
    metadata:
      name: prom-lb     #服务名称,可自定义
      namespace: monitoring
      labels:
        app: prometheus
        component: server
      annotations:
        kubernetes.io/elb.id: 038ff***     #请替换为集群所在VPC下的ELB实例ID,且ELB实例为公网访问类型
    spec:
      ports:
        - name: cce-service-0
          protocol: TCP
          port: 88             #服务端口号,可自定义
          targetPort: 9090     #Prometheus的默认端口号,无需更改
      selector:                #标签选择器可根据Prometheus Server实例的标签进行调整
        app.kubernetes.io/name: prometheus
        prometheus: server
      type: LoadBalancer

  3. 创建完成后在浏览器访问“负载均衡公网IP地址:服务端口”,访问Prometheus。您可以在Prometheus页面中搜索支持的监控项,验证指标是否采集成功。

    图1 访问Prometheus

support.huaweicloud.com/usermanual-cce/cce_10_0834.html