zoukankan      html  css  js  c++  java
  • prometheus operator监控coredns

    1、创建service

    apiVersion: v1
    kind: Service
    metadata:
      labels:
        app: prometheus-operator-coredns
        chart: prometheus-operator-7.4.0
        heritage: Tiller
        jobLabel: coredns
        release: pharos-prometheus-operator
      name: pharos-prometheus-operator-coredns
      namespace: kube-system
    spec:
      clusterIP: None
      ports:
      - name: http-metrics
        port: 9153
        protocol: TCP
        targetPort: 9153
      selector:
        k8s-app: kube-dns
      sessionAffinity: None
      type: ClusterIP
    

     2、创建serviceMonitor

    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      labels:
        app: prometheus-operator-coredns
        chart: prometheus-operator-7.4.0
        heritage: Tiller
        release: pharos-prometheus-operator
      name: pharos-prometheus-operator-coredns
      namespace: cattle-prometheus
    spec:
      endpoints:
      - bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
        port: http-metrics
      jobLabel: jobLabel
      namespaceSelector:
        matchNames:
        - kube-system
      selector:
        matchLabels:
          app: prometheus-operator-coredns
          release: pharos-prometheus-operator
    

    3、创建 prometheusrules

    apiVersion: monitoring.coreos.com/v1
    kind: PrometheusRule
    metadata:
      annotations:
        prometheus-operator-validated: "true"
      labels:
        app: prometheus-operator
        release: pharos-prometheus-operator
      name: coredns-panic
      namespace: cattle-prometheus
    spec:
      groups:
      - name: coredns-panic
        rules:
        - alert: coredns-panic
          annotations:
            description: Coredns panic count is {{ $value }},please check!
          expr: sum by(instance, job, namespace) (coredns_panic_count_total) >= 10
          for: 15m
          labels:
            alertname: coredns-panic
            severity: warning
    ---
    apiVersion: monitoring.coreos.com/v1
    kind: PrometheusRule
    metadata:
      annotations:
        prometheus-operator-validated: "true"
      labels:
        app: prometheus-operator
        release: pharos-prometheus-operator
      name: coredns-responses
      namespace: cattle-prometheus
    spec:
      groups:
      - name: coredns-responses
        rules:
        - alert: coredns-responses
          annotations:
            description: Coredns has longer response time, please check !
          expr: histogram_quantile(0.99, sum by(le, job) (rate(coredns_dns_request_duration_seconds_bucket[5m])))  *
            10 >= 3
          for: 15m
          labels:
            alertname: coredns-responses
            severity: warning
    
  • 相关阅读:
    最简单的jQuery插件
    SQL执行时间
    Resharper 8.2 注册码
    Module模式
    RestSharp使用
    使用MVC过滤器保存操作日志
    Ajax Post 类实例
    IBatis分页显示
    IBatis插入类的实例
    Topcoder SRM629 DIV2 解题报告
  • 原文地址:https://www.cnblogs.com/Wshile/p/13268510.html
Copyright © 2011-2022 走看看