如何在稳定/普罗米修斯图表中设置prometheus规则.yaml?

onl*_*ine 2 configuration charts yaml rules prometheus

使用官方Prometheus图表stable/prometheus.

自定义其values.yaml文件以设置alertmanager.yml文件和serverFiles区域.

rules: {}:

https://github.com/kubernetes/charts/blob/master/stable/prometheus/values.yaml#L598

是的{}.如何将真正的警报规则写成官方格式

例如,我尝试过:

  serverFiles:
    alerts: {}
    rules:
    # Alert for any instance that is unreachable for >5 minutes.
    - alert: InstanceDown
      expr: up == 0
      for: 5m
      labels:
        severity: page
      annotations:
        summary: "Instance {{ $labels.instance }} down"
      description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes."
Run Code Online (Sandbox Code Playgroud)

跑了$ helm install my_prometheus.然后pod出现了这个错误:

PersistentVolumeClaim is not bound: "sweet-terrier-prometheus-server"
Back-off restarting failed container
Error syncing pod
Run Code Online (Sandbox Code Playgroud)

onl*_*ine 9

serverFiles:
  alerts:
    groups:
    - name: NodeAlerts
      rules:
      - alert: NodeCPUUsage
        expr: (100 - (avg(irate(node_cpu{mode="idle"}[5m])) BY (instance) * 100)) > 75
        for: 2m
        labels:
          severity: alert
        annotations:
          description: '{{$labels.instance}}: CPU usage is above 75% (current value is:
            {{ $value }})'
          summary: '{{$labels.instance}}: High CPU usage detect
Run Code Online (Sandbox Code Playgroud)

规则适用于记录规则,警报适用于警报规则.

https://prometheus.io/docs/practices/rules/

  • 有没有办法在 helm 安装或升级期间“注入”规则,而不是修改“values.yaml”?比如在文件中添加规则或以某种方式? (2认同)