首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >helm values.yaml中的alerting_rules.yml

helm values.yaml中的alerting_rules.yml
EN

Stack Overflow用户
提问于 2021-03-19 23:30:25
回答 1查看 394关注 0票数 0

我已经使用helm图表将prometheus安装到了AWS EKS Kubernetes集群中,现在我正在尝试在values.yaml文件中为图表进行配置,现在我正在尝试添加警报。

文件中已经有一个示例,如下所示

代码语言:javascript
复制
## Prometheus server ConfigMap entries
##
serverFiles:

  ## Alerts configuration
  ## Ref: https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
  alerting_rules.yml: {}
  # groups:
  #   - name: Instances
  #     rules:
  #       - alert: InstanceDown
  #         expr: up == 0
  #         for: 5m
  #         labels:
  #           severity: page
  #         annotations:
  #           description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.'
  #           summary: 'Instance {{ $labels.instance }} down'

当我取消注释此示例并尝试更新helm部署时,我收到一个错误Error: cannot load values.yaml: error converting YAML to JSON: yaml: line 1282: did not find expected node content

它抱怨的行是中的groups:

代码语言:javascript
复制
serverFiles:


  ## Alerts configuration
  ## Ref: https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
  alerting_rules.yml: {
  groups:
  - name: Instances
    rules:
      - alert: InstanceDown
        expr: up == 0
        for: 5m
        labels:
          severity: page
        annotations:
          description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.'
          summary: 'Instance {{ $labels.instance }} down'
  }

我不确定我在这里做错了什么。

我尝试了另一个警报,但它给出了相同的错误

代码语言:javascript
复制
serverFiles:


  ## Alerts configuration
  ## Ref: https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
  alerting_rules.yml: {
    groups:
      - name: pod restarted
        rules:
        - alert: PodRestarted
          expr: job:rate(kube_pod_container_status_restarts_total[1h]) * 3600 > 1
          for: 5s
          labels:
            severity: High
          annotations:
            summary: Pod restarted
  }
EN

回答 1

Stack Overflow用户

发布于 2021-03-19 23:55:15

移除{}似乎解决了这个问题。

示例

代码语言:javascript
复制
serverFiles:


  ## Alerts configuration
  ## Ref: https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/
  alerting_rules.yml:
    groups:
      - name: pod restarted
        rules:
        - alert: PodRestarted
          expr: kube_pod_container_status_restarts_total < 1
          for: 0s
          labels:
            severity: High
          annotations:
            summary: Pod restarted
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66711093

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档