prometheus - helm values.yaml 中的 alerting_rules.yml
问题描述
我已经使用 helm chart 将 prometheus 安装到 AWS EKS Kubernetes 集群中,现在我正在尝试在该图表的 values.yaml 文件中配置我现在正在尝试添加警报。
文件中已经有一个示例,如下所示
## 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:
线路
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'
}
我不确定我在这里做错了什么。
我尝试了另一个警报,但它给出了同样的错误
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
}
解决方案
似乎删除 {} 解决了它。
例子
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
推荐阅读
- node.js - 如何从 node.js 脚本中获取 process.stdio?
- rabbitmq - 如何调试有关缺少绑定的 Rabbitmq 诊断错误
- python - 一个 GET 请求调用 Django 视图函数两次
- excel - 如何使用 VBA 和 Selenium 处理网页弹出窗口?
- c# - 如果条件为真,有没有办法告诉 if 语句什么都不做
- javascript - 将 mimeType:从 application/octate-stream 转换为 text/csv - Google Script
- java - Spring Boot - 异步方法未执行
- javassist - 使用检测,javassist 可以修改类文件,但是如何加载由 javassist 创建的新类
- ssis - 行分隔符不能与列分隔符相同
- mysql - 在SQL中查找数据库中所有表的最大值