【发布时间】:2021-06-17 00:49:42
【问题描述】:
我已经使用 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
}
【问题讨论】:
标签: prometheus kubernetes-helm