我已经使用helm图表将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
}发布于 2021-03-19 23:55:15
移除{}似乎解决了这个问题。
示例
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 restartedhttps://stackoverflow.com/questions/66711093
复制相似问题