• Prometheus ServiceMonitor


    Prometheus ServiceMonitor

     

    创建一个新的serviceMonitor就创建了一个prometheus的target

    [root@k8s-m1 ~]# cat ServiceMonitor.yaml 
    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      labels:
         k8s-app: xxx-exporter
      name: xxx
      namespace: prometheus 
    spec:
      endpoints:
      - interval: 15s
        port:  xxx-exporter
      jobLabel:  xxx-exporter-monitor 
      namespaceSelector:
        matchNames:
        - monitor                #目标服务的namespaces
      selector:
        matchLabels:
          k8s-app: xx-exporter  目标服务的labels
    
      namespaceSelector:
        any: true   选择所有的namespace

    上面ServiceMonitor是针对k8s集群内部服务监控,想监控集群外部的exporter通Endpoints实现

    # 为外部 exporter 服务设置 service
    kind: Service
    apiVersion: v1
    metadata:
      namespace: monitor
      name: service-mysql-xx
      labels:
        app: service-mysql-xx
    spec:
      ports:
        - protocol: TCP
          port: 9xx
          targetPort: 9xx
      type: ClusterIP
      clusterIP: None
    
    ---
    kind: Endpoints
    apiVersion: v1
    metadata:
      namespace: monitor
      name: service-mysql-xx
      labels:
        app: service-mysql-xx
    subsets:
      - addresses:
          - ip: x.x.x.x
        ports:
          - protocol: TCP
            port: 9xxx

    ServiceMonitor

    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
        name: service-mysql-xx
        labels:
            app: service-mysql-xx
    spec:
        selector:
            matchLabels:
                app: service-mysql-xx
            namespaceSelector:
                matchNames:
                - monitor
        endpoints:
        - port: metrics
          interval: 10s
          honorLabels: true
    所有的悲情叙事,都是因为你的基础体能不够
  • 相关阅读:
    由u盘安装Ubuntu引出的事件
    初试Ubuntu
    从error 中学习
    快手一面:牛客:字符串左移
    快手一面:Leetcode:最小栈
    十三、线程池
    十二、windows临界区、其他各种mutex互斥量
    十一、std::async深入
    LeetCode(703):找出数据流中的第K大元素
    LeetCode(1003):检查替换后的字符串
  • 原文地址:https://www.cnblogs.com/gaoyuechen/p/14690206.html
Copyright © 2020-2023  润新知