【发布时间】:2019-11-19 18:57:56
【问题描述】:
每当一个节点进入“未就绪”我的 Kubernetes 集群时,我都会为 prometheus 设置警报。每当发生这种情况时,我都会在 Slack 上收到通知。问题是我收到相同描述的通知“节点 xxxx 处于未就绪状态”,即使它重新启动也是如此。我正在尝试为节点的就绪状态使用一个变量,并在注释部分使用它。
我尝试使用“vars”和“when”将其分配给变量以在注释中使用它。
- name: NodeNotReady
rules:
- alert: K8SNodeNotReadyAlert
expr: kube_node_status_condition{condition="Ready",status="true"} == 0
for: 3m
vars:
- ready_status: "Ready"
when: kube_node_status_condition{condition="Ready",status="true"} == 1
- ready_status: "Not Ready"
when: kube_node_status_condition{condition="Ready",status="true"} == 0
labels:
severity: warning
annotations:
description: Node {{ $labels.node }} status is in {{ ready_status }}.
summary: Node status {{ ready_status }} Alert!
我想收到这些警报: 1.当节点为NotReady时:“Node prom-node status is in NotReady”。 2.当节点Ready时:“Node prom-node状态为NotReady。”
【问题讨论】:
标签: annotations yaml alert prometheus rules