From 3dd39f4bc0dc0cdc060d6fb90f9f2d3be86126b5 Mon Sep 17 00:00:00 2001 From: jneo8 Date: Tue, 14 Nov 2023 17:31:07 +0800 Subject: [PATCH 1/2] fix(alert): Ignore ipmi Entity Presence type alert Alert rule ipmi_generic_sensor_value ignoe type="Entity Presence" --- src/prometheus_alert_rules/ipmi_sensors.yaml | 4 ++-- tests/unit/test_alert_rules/test_ipmi_sensors.yaml | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/prometheus_alert_rules/ipmi_sensors.yaml b/src/prometheus_alert_rules/ipmi_sensors.yaml index b6b63d47..99a225cb 100644 --- a/src/prometheus_alert_rules/ipmi_sensors.yaml +++ b/src/prometheus_alert_rules/ipmi_sensors.yaml @@ -75,13 +75,13 @@ groups: LABELS = {{ $labels }} - alert: IPMISensorStateNotOk - expr: ipmi_generic_sensor_value{state=~"Warning|Critical"} + expr: ipmi_generic_sensor_value{state=~"Warning|Critical", type!="Entity Presence"} for: 0m labels: severity: "{{ toLower $labels.state }}" annotations: summary: IPMI sensor value in {{ toLower $labels.state }} state. (instance {{ $labels.instance }}) description: | - A sensor value, recorded by ipmi sensor, in {{ toLower $labels.state }} state. + A sensor value, recorded by ipmi sensor, in {{ toLower $labels.state }} state and ignore type Entity Presence. VALUE = {{ $value }} LABELS = {{ $labels }} diff --git a/tests/unit/test_alert_rules/test_ipmi_sensors.yaml b/tests/unit/test_alert_rules/test_ipmi_sensors.yaml index 018257af..48f63c50 100644 --- a/tests/unit/test_alert_rules/test_ipmi_sensors.yaml +++ b/tests/unit/test_alert_rules/test_ipmi_sensors.yaml @@ -214,6 +214,8 @@ tests: values: '1x15' - series: ipmi_generic_sensor_value{state="Critical", instance="ubuntu-12"} values: '50x15' + - series: ipmi_generic_sensor_value{state="Critical", instance="ubuntu-12", type="Entity Presence"} + values: '50x15' alert_rule_test: - eval_time: 0m @@ -226,7 +228,7 @@ tests: exp_annotations: summary: IPMI sensor value in warning state. (instance ubuntu-11) description: | - A sensor value, recorded by ipmi sensor, in warning state. + A sensor value, recorded by ipmi sensor, in warning state and ignore type Entity Presence. VALUE = 20 LABELS = map[__name__:ipmi_generic_sensor_value instance:ubuntu-11 state:Warning] - exp_labels: @@ -236,6 +238,6 @@ tests: exp_annotations: summary: IPMI sensor value in critical state. (instance ubuntu-12) description: | - A sensor value, recorded by ipmi sensor, in critical state. + A sensor value, recorded by ipmi sensor, in critical state and ignore type Entity Presence. VALUE = 50 LABELS = map[__name__:ipmi_generic_sensor_value instance:ubuntu-12 state:Critical] From ac0441de1a70dbb7edf395b39d7561d4a29babf0 Mon Sep 17 00:00:00 2001 From: jneo8 Date: Thu, 16 Nov 2023 13:55:43 +0800 Subject: [PATCH 2/2] docs: Change the wording of alert description --- src/prometheus_alert_rules/ipmi_sensors.yaml | 2 +- tests/unit/test_alert_rules/test_ipmi_sensors.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/prometheus_alert_rules/ipmi_sensors.yaml b/src/prometheus_alert_rules/ipmi_sensors.yaml index 99a225cb..93ebf02e 100644 --- a/src/prometheus_alert_rules/ipmi_sensors.yaml +++ b/src/prometheus_alert_rules/ipmi_sensors.yaml @@ -82,6 +82,6 @@ groups: annotations: summary: IPMI sensor value in {{ toLower $labels.state }} state. (instance {{ $labels.instance }}) description: | - A sensor value, recorded by ipmi sensor, in {{ toLower $labels.state }} state and ignore type Entity Presence. + A sensor value, recorded by ipmi sensor, in {{ toLower $labels.state }} state. Entity Presence sensors are ignored. VALUE = {{ $value }} LABELS = {{ $labels }} diff --git a/tests/unit/test_alert_rules/test_ipmi_sensors.yaml b/tests/unit/test_alert_rules/test_ipmi_sensors.yaml index 48f63c50..c58e8c7b 100644 --- a/tests/unit/test_alert_rules/test_ipmi_sensors.yaml +++ b/tests/unit/test_alert_rules/test_ipmi_sensors.yaml @@ -228,7 +228,7 @@ tests: exp_annotations: summary: IPMI sensor value in warning state. (instance ubuntu-11) description: | - A sensor value, recorded by ipmi sensor, in warning state and ignore type Entity Presence. + A sensor value, recorded by ipmi sensor, in warning state. Entity Presence sensors are ignored. VALUE = 20 LABELS = map[__name__:ipmi_generic_sensor_value instance:ubuntu-11 state:Warning] - exp_labels: @@ -238,6 +238,6 @@ tests: exp_annotations: summary: IPMI sensor value in critical state. (instance ubuntu-12) description: | - A sensor value, recorded by ipmi sensor, in critical state and ignore type Entity Presence. + A sensor value, recorded by ipmi sensor, in critical state. Entity Presence sensors are ignored. VALUE = 50 LABELS = map[__name__:ipmi_generic_sensor_value instance:ubuntu-12 state:Critical]