]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: add test cases and validation using tox
authorPaul Cuzner <pcuzner@redhat.com>
Tue, 19 Oct 2021 00:07:02 +0000 (13:07 +1300)
committerAvan Thakkar <athakkar@redhat.com>
Thu, 6 Jan 2022 09:51:54 +0000 (15:21 +0530)
Focus all tests inside a tests directory, and use pytest/tox to
perform validation of the overall content. tox tests also use
promtool if available to provide rule checks and unittest runs.

In addition to these checks a validate_rules script provides the
format, and content checks against all rules - which is also
called via tox (but can be run independently too)

Signed-off-by: Paul Cuzner <pcuzner@redhat.com>
12 files changed:
monitoring/prometheus/alerts/ceph_default_alerts.yml
monitoring/prometheus/alerts/test_alerts.yml [deleted file]
monitoring/prometheus/tests/README.md [new file with mode: 0644]
monitoring/prometheus/tests/__init__.py [new file with mode: 0644]
monitoring/prometheus/tests/requirements.txt [new file with mode: 0644]
monitoring/prometheus/tests/settings.py [new file with mode: 0644]
monitoring/prometheus/tests/test_alerts.yml [new file with mode: 0644]
monitoring/prometheus/tests/test_syntax.py [new file with mode: 0755]
monitoring/prometheus/tests/test_unittests.py [new file with mode: 0644]
monitoring/prometheus/tests/tox.ini [new file with mode: 0644]
monitoring/prometheus/tests/utils.py [new file with mode: 0644]
monitoring/prometheus/tests/validate_rules.py [new file with mode: 0755]

index 420472d35eebfc6b87e6984fe6b4c35030031e86..4b9ea51ebe1d86fa83af5e13aac4b2d44b6edc65 100644 (file)
@@ -35,7 +35,7 @@ groups:
           type: ceph_default
           oid: 1.3.6.1.4.1.50495.15.1.2.3.1
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-down
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-down
           description: |
             {{ $min := query "floor(count(ceph_mon_metadata) / 2) +1" | first | value }}Quorum requires a majority of monitors (x {{ $min }}) to be active
             Without quorum the cluster will become inoperable, affecting all connected clients and services.
@@ -51,7 +51,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-down
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-down
           description: |
             {{ $down := query "count(ceph_mon_quorum_status == 0)" | first | value }}{{ $s := "" }}{{ if gt $down 1.0 }}{{ $s = "s" }}{{ end }}You have {{ $down }} monitor{{ $s }} down.
             Quorum is still intact, but the loss of further monitors will make your cluster inoperable.
@@ -67,7 +67,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-disk-crit
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-disk-crit
           description: |
             The free space available to a monitor's store is critically low (<5% by default).
             You should increase the space available to the monitor(s). The
@@ -83,7 +83,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-disk-low
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-disk-low
           description: |
             The space available to a monitor's store is approaching full (>70% is the default).
             You should increase the space available to the monitor store. The
@@ -99,7 +99,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-clock-skew
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-clock-skew
           description: |
             The ceph monitors rely on a consistent time reference to maintain
             quorum and cluster consistency. This event indicates that at least
@@ -144,7 +144,7 @@ groups:
           type: ceph_default
           oid: 1.3.6.1.4.1.50495.15.1.2.4.2
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-down
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-down
           description: |
             {{ $num := query "count(ceph_osd_up == 0)" | first | value }}{{ $s := "" }}{{ if gt $num 1.0 }}{{ $s = "s" }}{{ end }}{{ $num }} OSD{{ $s }} down for over 5mins.
 
@@ -161,7 +161,7 @@ groups:
           type: ceph_default
           oid: 1.3.6.1.4.1.50495.15.1.2.4.3
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-nearfull
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-nearfull
           description: |
             One or more OSDs have reached their NEARFULL threshold
 
@@ -174,7 +174,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-full
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-full
           description: |
             An OSD has reached it's full threshold. Writes from all pools that share the
             affected OSD will be blocked.
@@ -187,7 +187,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-backfillfull
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-backfillfull
           description: |
             An OSD has reached it's BACKFILL FULL threshold. This will prevent rebalance operations
             completing for some pools. Check the current capacity utilisation with 'ceph df'
@@ -200,7 +200,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-too-many-repairs
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-too-many-repairs
           description: |
             Reads from an OSD have used a secondary PG to return data to the client, indicating
             a potential failing disk.
@@ -231,7 +231,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#bluestore-disk-size-mismatch
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#bluestore-disk-size-mismatch
           description: |
             One or more OSDs have an internal inconsistency between the size of the physical device and it's metadata.
             This could lead to the OSD(s) crashing in future. You should redeploy the effected OSDs.
@@ -242,7 +242,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#id2
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#id2
           description: |
             The device health module has determined that one or more devices will fail
             soon. To review the device states use 'ceph device ls'. To show a specific
@@ -257,7 +257,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#device-health-toomany
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#device-health-toomany
           description: |
             The device health module has determined that the number of devices predicted to
             fail can not be remediated automatically, since it would take too many osd's out of
@@ -270,7 +270,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#device-health-in-use
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#device-health-in-use
           description: |
             The device health module has determined that one or more devices will fail
             soon, but the normal process of relocating the data on the device to other
@@ -291,7 +291,7 @@ groups:
           type: ceph_default
           oid: 1.3.6.1.4.1.50495.15.1.2.4.4
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/troubleshooting/troubleshooting-osd/#flapping-osds
+          documentation: https://docs.ceph.com/en/latest/rados/troubleshooting/troubleshooting-osd#flapping-osds
           description: >
             OSD {{ $labels.ceph_daemon }} on {{ $labels.hostname }} was
             marked down and back up at {{ $value | humanize }} times once a
@@ -306,7 +306,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#bluestore-spurious-read-errors
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#bluestore-spurious-read-errors
           description: >
             An OSD has encountered read errors, but the OSD has recovered by retrying
             the reads. This may indicate an issue with the Hardware or Kernel.
@@ -338,7 +338,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/cephfs/health-messages/#cephfs-health-messages
+          documentation: https://docs.ceph.com/en/latest/cephfs/health-messages#cephfs-health-messages
           description: >
             The filesystems metadata has been corrupted. Data access
             may be blocked.
@@ -352,7 +352,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/cephfs/health-messages/#cephfs-health-messages
+          documentation: https://docs.ceph.com/en/latest/cephfs/health-messages#cephfs-health-messages
           description: >
             The filesystem has switched to READ ONLY due to an unexpected
             write error, when writing to the metadata pool
@@ -369,7 +369,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#recent-mgr-module-crash
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#recent-mgr-module-crash
           description: >
             One or more mgr modules have crashed and are yet to be acknowledged by the administrator. A
             crashed module may impact functionality within the cluster. Use the 'ceph crash' commands to
@@ -423,7 +423,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-damaged
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-damaged
           description: >
             During data consistency checks (scrub), at least one PG has been flagged as being
             damaged or inconsistent.
@@ -438,7 +438,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-recovery-full
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-recovery-full
           description: >
             Data redundancy may be reduced, or is at risk, since one or more OSDs are at or above their
             'full' threshold. Add more capacity to the cluster, or delete unwanted data.
@@ -450,7 +450,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-availability
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-availability
           description: >
             Data availability is reduced impacting the clusters abilty to service I/O to some data. One or
             more placement groups (PGs) are in a state that blocks IO.
@@ -461,7 +461,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-backfill-full
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-backfill-full
           description: >
             Data redundancy may be at risk due to lack of free space within the cluster. One or more OSDs
             have breached their 'backfillfull' threshold. Add more capacity, or delete unwanted data.
@@ -472,7 +472,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-not-scrubbed
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-not-scrubbed
           description: |
             One or more PGs have not been scrubbed recently. The scrub process is a data integrity
             feature, protectng against bit-rot. It checks that objects and their metadata (size and
@@ -488,7 +488,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-not-deep-scrubbed
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-not-deep-scrubbed
           description: |
             One or more PGs have not been deep scrubbed recently. Deep scrub is a data integrity
             feature, protectng against bit-rot. It compares the contents of objects and their
@@ -627,7 +627,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pool-full
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pool-full
           description: |
             A pool has reached it's MAX quota, or the OSDs supporting the pool
             have reached their FULL threshold. Until this is resolved, writes to
@@ -663,7 +663,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#slow-ops
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#slow-ops
           description: >
             {{ $value }} OSD requests are taking too long to process (osd_op_complaint_time exceeded)
 # cephadm alerts
@@ -699,7 +699,7 @@ groups:
           severity: warning
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/cephadm/operations/#cephadm-paused
+          documentation: https://docs.ceph.com/en/latest/cephadm/operations#cephadm-paused
           description: >
             Cluster management has been paused manually. This will prevent the
             orchestrator from service management and reconciliation. If this is
@@ -731,7 +731,7 @@ groups:
           severity: critical
           type: ceph_default
         annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#object-unfound
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#object-unfound
           description: |
             A version of a RADOS object can not be found, even though all OSDs are up. I/O
             requests for this object from clients will block (hang). Resolving this issue may
diff --git a/monitoring/prometheus/alerts/test_alerts.yml b/monitoring/prometheus/alerts/test_alerts.yml
deleted file mode 100644 (file)
index 1e855c0..0000000
+++ /dev/null
@@ -1,1806 +0,0 @@
-rule_files:
-  - ceph_default_alerts.yml
-evaluation_interval: 5m
-tests:
- # health error
- - interval: 5m
-   input_series:
-    - series: 'ceph_health_status{instance="ceph:9283",job="ceph"}'
-      values: '2 2 2 2 2 2 2'
-   promql_expr_test:
-    - expr: ceph_health_status == 2
-      eval_time: 5m
-      exp_samples:
-       - labels: 'ceph_health_status{instance="ceph:9283",job="ceph"}'
-         value: 2
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: health error
-    - eval_time: 6m
-      alertname: health error
-      exp_alerts:
-      - exp_labels:
-          instance: ceph:9283
-          job: ceph
-          oid: 1.3.6.1.4.1.50495.15.1.2.2.1
-          type: ceph_default
-          severity: critical
-        exp_annotations:
-          description: >
-            Ceph in HEALTH_ERROR state for more than 5 minutes.
-            Please check "ceph health detail" for more information.
-
- # health warning
- - interval: 5m
-   input_series:
-    - series: 'ceph_health_status{instance="ceph:9283",job="ceph"}'
-      values: '1 1 1 1 1 1 1 1 1 1'
-   promql_expr_test:
-     - expr: ceph_health_status == 1
-       eval_time: 15m
-       exp_samples:
-         - labels: 'ceph_health_status{instance="ceph:9283",job="ceph"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 10m
-      alertname: health warn
-    - eval_time: 20m
-      alertname: health warn
-      exp_alerts:
-      - exp_labels:
-          instance: ceph:9283
-          job: ceph
-          oid: 1.3.6.1.4.1.50495.15.1.2.2.2
-          type: ceph_default
-          severity: warning
-        exp_annotations:
-          description: >
-            Ceph has been in HEALTH_WARN for more than 15 minutes.
-            Please check "ceph health detail" for more information.
-
- # low monitor quorum count
-#  - interval: 1m
-#    input_series:
-#     - series: 'ceph_mon_quorum_status{ceph_daemon="mon.a",instance="ceph:9283",
-#       job="ceph"}'
-#       values: '1 1 1 1 1'
-#     - series: 'ceph_mon_quorum_status{ceph_daemon="mon.b",instance="ceph:9283",
-#       job="ceph"}'
-#       values: '1 1 1 1 1'
-#     - series: 'ceph_mon_quorum_status{ceph_daemon="mon.c",instance="ceph:9283",
-#       job="ceph"}'
-#       values: '0 0 0 0 0'
-#     - series: 'ceph_mon_metadata{ceph_daemon="mon.a",ceph_version="ceph version
-#       17.0.0-189-g3558fd72 (3558fd7291855971aa6481a2ade468ad61fbb346) pacific
-#       (dev)",hostname="ceph",instance="ceph:9283",job="ceph",
-#       public_addr="172.20.0.2",rank="0"}'
-#       values: '1 1 1 1 1'
-#     - series: 'ceph_mon_metadata{ceph_daemon="mon.b",ceph_version="ceph version
-#       17.0.0-189-g3558fd72 (3558fd7291855971aa6481a2ade468ad61fbb346) pacific
-#       (dev)",hostname="ceph",instance="ceph:9283",job="ceph",
-#       public_addr="172.20.0.2",rank="1"}'
-#       values: '1 1 1 1 1'
-#     - series: 'ceph_mon_metadata{ceph_daemon="mon.c",ceph_version="ceph version
-#       17.0.0-189-g3558fd72 (3558fd7291855971aa6481a2ade468ad61fbb346) pacific
-#       (dev)",hostname="ceph",instance="ceph:9283",job="ceph",
-#       public_addr="172.20.0.2",rank="2"}'
-#       values: '1 1 1 1 1'
-#    promql_expr_test:
-#      - expr: sum(ceph_mon_quorum_status) < 3
-#        eval_time: 1m
-#        exp_samples:
-#          - labels: '{}'
-#            value: 2
-#    alert_rule_test:
-#     - eval_time: 1m
-#       alertname: low monitor quorum count
-#       exp_alerts:
-#       - exp_labels:
-#           oid: 1.3.6.1.4.1.50495.15.1.2.3.1
-#           type: ceph_default
-#           severity: critical
-#         exp_annotations:
-#           description: |
-#             Monitor count in quorum is below three.
-
-#             Only 2 of 3 monitors are active.
-
-#             The following monitors are down:
-#               - mon.c on ceph
-
-
- # 10% OSDs down
- - interval: 1m
-   input_series:
-    - series: 'ceph_osd_up{ceph_daemon="osd.0",instance="ceph:9283",job="ceph"}'
-      values: '1 1 1 1 1'
-    - series: 'ceph_osd_up{ceph_daemon="osd.1",instance="ceph:9283",job="ceph"}'
-      values: '0 0 0 0 0'
-    - series: 'ceph_osd_up{ceph_daemon="osd.2",instance="ceph:9283",job="ceph"}'
-      values: '1 1 1 1 1'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1'
-   promql_expr_test:
-     - expr: count(ceph_osd_up == 0) / count(ceph_osd_up) * 100 >= 10
-       eval_time: 1m
-       exp_samples:
-         - labels: '{}'
-           value: 3.333333333333333E+01
-   alert_rule_test:
-     - eval_time: 1m
-       alertname: 10% OSDs down
-       exp_alerts:
-       - exp_labels:
-           oid: 1.3.6.1.4.1.50495.15.1.2.4.1
-           type: ceph_default
-           severity: critical
-         exp_annotations:
-           description: |
-             33.33% or 1 of 3 OSDs are down (≥ 10%).
-
-             The following OSDs are down:
-               - osd.1 on ceph
-
- # OSD down
-#  - interval: 1m
-#    input_series:
-#     - series: 'ceph_osd_up{ceph_daemon="osd.0",instance="ceph:9283",job="ceph"}'
-#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-#     - series: 'ceph_osd_up{ceph_daemon="osd.1",instance="ceph:9283",job="ceph"}'
-#       values: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
-#     - series: 'ceph_osd_up{ceph_daemon="osd.2",instance="ceph:9283",job="ceph"}'
-#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
-#       ceph_version="ceph version 17.0.0-189-g3558fd72
-#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-#       public_addr="172.20.0.2"}'
-#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
-#       ceph_version="ceph version 17.0.0-189-g3558fd72
-#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-#       public_addr="172.20.0.2"}'
-#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
-#       ceph_version="ceph version 17.0.0-189-g3558fd72
-#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-#       public_addr="172.20.0.2"}'
-#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-#    promql_expr_test:
-#      - expr: count(ceph_osd_up == 0) > 0
-#        eval_time: 1m
-#        exp_samples:
-#          - labels: '{}'
-#            value: 1
-#    alert_rule_test:
-#      - eval_time: 15m
-#        alertname: OSD down
-#        exp_alerts:
-#        - exp_labels:
-#            oid: 1.3.6.1.4.1.50495.15.1.2.4.2
-#            type: ceph_default
-#            severity: warning
-#          exp_annotations:
-#            description: |
-
-#              1 OSD down for more than 15 minutes.
-
-#              1 of 3 OSDs are down.
-
-#              The following OSD is down:
-#                  - osd.1 on ceph
-
-# OSDs near full
-#  - interval: 1m
-#    input_series:
-#     - series: 'ceph_osd_stat_bytes_used{ceph_daemon="osd.0",instance="ceph:9283"
-#       ,job="ceph"}'
-#       values: '1076310016 1076310016 1076310016 1076310016 1076310016
-#       1076310016'
-#     - series: 'ceph_osd_stat_bytes_used{ceph_daemon="osd.1",instance="ceph:9283"
-#       ,job="ceph"}'
-#       values: '1076310016 1076310016 1076310016 1076310016 1076310016
-#       1076310016'
-#     - series: 'ceph_osd_stat_bytes_used{ceph_daemon="osd.2",instance="ceph:9283"
-#       ,job="ceph"}'
-#       values: '1076310016 1076310016 1076310016 1076310016 1076310016
-#       100856561909.76'
-#     - series: 'ceph_osd_stat_bytes{ceph_daemon="osd.0",instance="ceph:9283"
-#       ,job="ceph"}'
-#       values: '108447916032 108447916032 108447916032 108447916032 108447916032
-#       108447916032'
-#     - series: 'ceph_osd_stat_bytes{ceph_daemon="osd.1",instance="ceph:9283"
-#       ,job="ceph"}'
-#       values: '108447916032 108447916032 108447916032 108447916032 108447916032
-#       108447916032'
-#     - series: 'ceph_osd_stat_bytes{ceph_daemon="osd.2",instance="ceph:9283"
-#       ,job="ceph"}'
-#       values: '108447916032 108447916032 108447916032 108447916032 108447916032
-#       108447916032'
-#     - series: 'ceph_osd_up{ceph_daemon="osd.0",instance="ceph:9283",job="ceph"}'
-#       values: '1 1 1 1 1 1'
-#     - series: 'ceph_osd_up{ceph_daemon="osd.1",instance="ceph:9283",job="ceph"}'
-#       values: '1 1 1 1 1 1'
-#     - series: 'ceph_osd_up{ceph_daemon="osd.2",instance="ceph:9283",job="ceph"}'
-#       values: '1 1 1 1 1 1'
-#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
-#       ceph_version="ceph version 17.0.0-189-g3558fd72
-#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-#       public_addr="172.20.0.2"}'
-#       values: '1 1 1 1 1 1'
-#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
-#       ceph_version="ceph version 17.0.0-189-g3558fd72
-#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-#       public_addr="172.20.0.2"}'
-#       values: '1 1 1 1 1 1'
-#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
-#       ceph_version="ceph version 17.0.0-189-g3558fd72
-#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-#       public_addr="172.20.0.2"}'
-#       values: '1 1 1 1 1 1'
-#    promql_expr_test:
-#      - expr: |
-#          (
-#            ((ceph_osd_stat_bytes_used / ceph_osd_stat_bytes) and on(ceph_daemon)
-#            ceph_osd_up == 1) * on(ceph_daemon) group_left(hostname)
-#            ceph_osd_metadata
-#          ) * 100 > 90
-
-#        eval_time: 5m
-#        exp_samples:
-#          - labels: '{ceph_daemon="osd.2",hostname="ceph",instance="ceph:9283",
-#            job="ceph"}'
-#            value: 9.3E+01
-#    alert_rule_test:
-#      - eval_time: 10m
-#        alertname: OSDs near full
-#        exp_alerts:
-#        - exp_labels:
-#            ceph_daemon: osd.2
-#            hostname: ceph
-#            instance: ceph:9283
-#            job: ceph
-#            oid: 1.3.6.1.4.1.50495.15.1.2.4.3
-#            type: ceph_default
-#            severity: critical
-#          exp_annotations:
-#            description: >
-#              OSD osd.2 on ceph is dangerously full: 93%
-
- # flapping OSD
- - interval: 1s
-   input_series:
-    - series: 'ceph_osd_up{ceph_daemon="osd.0",instance="ceph:9283",job="ceph"}'
-      values: '1+1x100'
-    - series: 'ceph_osd_up{ceph_daemon="osd.1",instance="ceph:9283",job="ceph"}'
-      values: '1+0x100'
-    - series: 'ceph_osd_up{ceph_daemon="osd.2",instance="ceph:9283",job="ceph"}'
-      values: '1+0x100'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1 1'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1 1'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1 1'
-   promql_expr_test:
-     - expr: |
-         (
-           rate(ceph_osd_up[5m])
-           * on(ceph_daemon) group_left(hostname) ceph_osd_metadata
-         ) * 60 > 1
-       eval_time: 1m
-       exp_samples:
-         - labels: '{ceph_daemon="osd.0", hostname="ceph", instance="ceph:9283",
-           job="ceph"}'
-           value: 1.2200000000000001E+01
-   alert_rule_test:
-     - eval_time: 5m
-       alertname: Flapping OSD
-       exp_alerts:
-       - exp_labels:
-           ceph_daemon: osd.0
-           hostname: ceph
-           instance: ceph:9283
-           job: ceph
-           oid: 1.3.6.1.4.1.50495.15.1.2.4.4
-           severity: warning
-           type: ceph_default
-         exp_annotations:
-           documentation: https://docs.ceph.com/en/latest/rados/troubleshooting/troubleshooting-osd/#flapping-osds
-           description: >
-              OSD osd.0 on ceph was
-              marked down and back up at 20.1 times once a minute for 5 minutes.
-              This could indicate a network issue (latency, packet drop, disruption)
-              on the clusters "cluster network". Check the network environment on the
-              listed host(s).
-
- # high pg count deviation
- - interval: 1m
-   input_series:
-    - series: 'ceph_osd_numpg{ceph_daemon="osd.0",instance="ceph:9283",
-      job="ceph"}'
-      values: '100 100 100 100 100 160'
-    - series: 'ceph_osd_numpg{ceph_daemon="osd.1",instance="ceph:9283",
-      job="ceph"}'
-      values: '100 100 100 100 100 320'
-    - series: 'ceph_osd_numpg{ceph_daemon="osd.2",instance="ceph:9283",
-      job="ceph"}'
-      values: '100 100 100 100 100 160'
-    - series: 'ceph_osd_numpg{ceph_daemon="osd.3",instance="ceph:9283",
-      job="ceph"}'
-      values: '100 100 100 100 100 160'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1 1'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1 1'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1 1'
-    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.3",
-      ceph_version="ceph version 17.0.0-189-g3558fd72
-      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
-      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
-      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
-      public_addr="172.20.0.2"}'
-      values: '1 1 1 1 1 1'
-   promql_expr_test:
-     - expr: |
-         abs(
-           (
-             (ceph_osd_numpg > 0) - on (job) group_left avg(ceph_osd_numpg > 0)
-             by (job)
-           ) / on (job) group_left avg(ceph_osd_numpg > 0) by (job)
-         ) * on(ceph_daemon) group_left(hostname) ceph_osd_metadata > 0.30
-
-       eval_time: 5m
-       exp_samples:
-         - labels: '{ceph_daemon="osd.1", hostname="ceph", instance="ceph:9283",
-           job="ceph"}'
-           value: 6E-01
-   alert_rule_test:
-     - eval_time: 10m
-       alertname: high pg count deviation
-       exp_alerts:
-       - exp_labels:
-           ceph_daemon: osd.1
-           hostname: ceph
-           instance: ceph:9283
-           job: ceph
-           oid: 1.3.6.1.4.1.50495.15.1.2.4.5
-           severity: warning
-           type: ceph_default
-         exp_annotations:
-           description: >
-              OSD osd.1 on ceph deviates
-              by more than 30% from average PG count.
-
- # pgs inactive
- - interval: 1m
-   input_series:
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name="device_health_metrics",pool_id="1"}'
-      values: '1 1 1 1 1 1 1 1'
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name="device_health_metrics",pool_id="2"}'
-      values: '1 1 1 1 1 1 1 1'
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name="device_health_metrics",pool_id="3"}'
-      values: '1 1 1 1 1 1 1 1'
-    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="1"}'
-      values: '1 1 1 1 1 1 1 1'
-    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="2"}'
-      values: '32 32 32 32 32 32 32 32'
-    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="3"}'
-      values: '33 32 32 32 32 33 33 32'
-    - series: 'ceph_pg_active{instance="ceph:9283",job="ceph",pool_id="1"}'
-      values: '1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_pg_active{instance="ceph:9283",job="ceph",pool_id="2"}'
-      values: '32 32 32 32 32 32 32 32'
-    - series: 'ceph_pg_active{instance="ceph:9283",job="ceph",pool_id="3"}'
-      values: '32 32 32 32 32 32 32 32'
-   promql_expr_test:
-     - expr: ceph_pool_metadata * on(pool_id,instance) group_left()
-             (ceph_pg_total - ceph_pg_active) > 0
-       eval_time: 5m
-       exp_samples:
-         - labels: '{instance="ceph:9283", job="ceph",
-           name="device_health_metrics",
-           pool_id="3"}'
-           value: 1
-   alert_rule_test:
-     - eval_time: 5m
-       alertname: pgs inactive
-       exp_alerts:
-       - exp_labels:
-           instance: ceph:9283
-           job: ceph
-           name: device_health_metrics
-           oid: 1.3.6.1.4.1.50495.15.1.2.7.1
-           pool_id: 3
-           severity: critical
-           type: ceph_default
-         exp_annotations:
-           description: >
-              1 PGs have been inactive for more than 5 minutes in pool
-              device_health_metrics.
-              Inactive placement groups aren't able to serve read/write
-              requests.
-
- #pgs unclean
- - interval: 1m
-   input_series:
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name="device_health_metrics",pool_id="1"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name="device_health_metrics",pool_id="2"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name="device_health_metrics",pool_id="3"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="1"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="2"}'
-      values: '32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
-      32 32 32'
-    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="3"}'
-      values: '33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
-      33 33'
-    - series: 'ceph_pg_clean{instance="ceph:9283",job="ceph",pool_id="1"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_pg_clean{instance="ceph:9283",job="ceph",pool_id="2"}'
-      values: '32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
-      32 32'
-    - series: 'ceph_pg_clean{instance="ceph:9283",job="ceph",pool_id="3"}'
-      values: '32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
-      32 32'
-   promql_expr_test:
-     - expr: ceph_pool_metadata * on(pool_id,instance) group_left()
-             (ceph_pg_total - ceph_pg_clean) > 0
-       eval_time: 15m
-       exp_samples:
-         - labels: '{instance="ceph:9283", job="ceph",
-           name="device_health_metrics", pool_id="3"}'
-           value: 1
-   alert_rule_test:
-     - eval_time: 16m
-       alertname: pgs unclean
-       exp_alerts:
-       - exp_labels:
-           instance: ceph:9283
-           job: ceph
-           name: device_health_metrics
-           oid: 1.3.6.1.4.1.50495.15.1.2.7.2
-           pool_id: 3
-           severity: warning
-           type: ceph_default
-         exp_annotations:
-           description: >
-              1 PGs haven't been clean for more than 15 minutes in pool
-              device_health_metrics.
-              Unclean PGs haven't been able to completely recover from a
-              previous failure.
-
- # root volume full
- - interval: 1m
-   input_series:
-    - series: 'node_filesystem_avail_bytes{device="/dev/mapper/fedora_localhost
-      --live-home",fstype="ext4",instance="node-exporter",job="node-exporter",
-      mountpoint="/"}'
-      values: '35336400896 35336400896 35336400896 35336400896 35336400896
-      3525385519.104 3533640089'
-    - series: 'node_filesystem_size_bytes{device="/dev/mapper/fedora_localhost
-      --live-home",fstype="ext4",instance="node-exporter",job="node-exporter",
-      mountpoint="/"}'
-      values: '73445531648 73445531648 73445531648 73445531648 73445531648
-      73445531648 73445531648'
-   promql_expr_test:
-     - expr: node_filesystem_avail_bytes{mountpoint="/"} /
-             node_filesystem_size_bytes{mountpoint="/"} * 100 < 5
-       eval_time: 5m
-       exp_samples:
-         - labels: '{device="/dev/mapper/fedora_localhost --live-home",
-           fstype="ext4", instance="node-exporter", job="node-exporter",
-           mountpoint="/"}'
-           value: 4.8E+00
-   alert_rule_test:
-     - eval_time: 10m
-       alertname: root volume full
-       exp_alerts:
-       - exp_labels:
-           device: /dev/mapper/fedora_localhost --live-home
-           fstype: ext4
-           instance: node-exporter
-           job: node-exporter
-           mountpoint: /
-           oid: 1.3.6.1.4.1.50495.15.1.2.8.1
-           severity: critical
-           type: ceph_default
-         exp_annotations:
-           description: >
-              Root volume (OSD and MON store) is dangerously full: 4.811% free.
-
- # network packets dropped
- - interval: 1s
-   input_series:
-    - series: 'node_network_receive_drop_total{device="eth0",
-      instance="node-exporter",job="node-exporter"}'
-      values: '1+1x500'
-    - series: 'node_network_transmit_drop_total{device="eth0",
-      instance="node-exporter",job="node-exporter"}'
-      values: '1+1x500'
-   promql_expr_test:
-     - expr: |
-         (
-           increase(node_network_receive_drop_total{device!="lo"}[1m]) +
-           increase(node_network_transmit_drop_total{device!="lo"}[1m])
-         ) / (
-           increase(node_network_receive_packets_total{device!="lo"}[1m]) +
-           increase(node_network_transmit_packets_total{device!="lo"}[1m])
-         ) >= 0.0001 or (
-           increase(node_network_receive_drop_total{device!="lo"}[1m]) +
-           increase(node_network_transmit_drop_total{device!="lo"}[1m])
-         ) >= 10
-
-       eval_time: 5m
-       exp_samples:
-         - labels: '{device="eth0", instance="node-exporter",
-           job="node-exporter"}'
-           value: 1.2E+02
-   alert_rule_test:
-     - eval_time: 5m
-       alertname: network packets dropped
-       exp_alerts:
-       - exp_labels:
-           device: eth0
-           instance: node-exporter
-           job: node-exporter
-           oid: 1.3.6.1.4.1.50495.15.1.2.8.2
-           severity: warning
-           type: ceph_default
-         exp_annotations:
-           description: >
-              Node node-exporter experiences packet drop > 0.01% or >
-              10 packets/s on interface eth0.
-
- # network packets errors
- - interval: 1s
-   input_series:
-    - series: 'node_network_receive_errs_total{device="eth0",
-      instance="node-exporter",job="node-exporter"}'
-      values: '1+1x500'
-    - series: 'node_network_transmit_errs_total{device="eth0",
-      instance="node-exporter",job="node-exporter"}'
-      values: '1+1x500'
-   promql_expr_test:
-     - expr: |
-         (
-           increase(node_network_receive_errs_total{device!="lo"}[1m]) +
-           increase(node_network_transmit_errs_total{device!="lo"}[1m])
-         ) / (
-           increase(node_network_receive_packets_total{device!="lo"}[1m]) +
-           increase(node_network_transmit_packets_total{device!="lo"}[1m])
-         ) >= 0.0001 or (
-           increase(node_network_receive_errs_total{device!="lo"}[1m]) +
-           increase(node_network_transmit_errs_total{device!="lo"}[1m])
-         ) >= 10
-
-       eval_time: 5m
-       exp_samples:
-         - labels: '{device="eth0", instance="node-exporter",
-           job="node-exporter"}'
-           value: 1.2E+02
-   alert_rule_test:
-     - eval_time: 5m
-       alertname: network packet errors
-       exp_alerts:
-       - exp_labels:
-           device: eth0
-           instance: node-exporter
-           job: node-exporter
-           oid: 1.3.6.1.4.1.50495.15.1.2.8.3
-           severity: warning
-           type: ceph_default
-         exp_annotations:
-           description: >
-              Node node-exporter experiences packet errors > 0.01% or > 10
-              packets/s on interface eth0.
-
- # MTU Mismatch
- - interval: 1m
-   input_series:
-    - series: 'node_network_mtu_bytes{device="eth0",instance="node-exporter",
-      job="node-exporter"}'
-      values: '1500 1500 1500 1500 1500'
-    - series: 'node_network_mtu_bytes{device="eth1",instance="node-exporter",
-      job="node-exporter"}'
-      values: '1500 1500 1500 1500 1500'
-    - series: 'node_network_mtu_bytes{device="eth2",instance="node-exporter",
-      job="node-exporter"}'
-      values: '1500 1500 1500 1500 1500'
-    - series: 'node_network_mtu_bytes{device="eth3",instance="node-exporter",
-      job="node-exporter"}'
-      values: '1500 1500 1500 1500 1500'
-    - series: 'node_network_mtu_bytes{device="eth4",instance="node-exporter",
-      job="node-exporter"}'
-      values: '9000 9000 9000 9000 9000'
-    - series: 'node_network_up{device="eth0",instance="node-exporter",
-      job="node-exporter"}'
-      values: '0 0 0 0 0'
-    - series: 'node_network_up{device="eth1",instance="node-exporter",
-      job="node-exporter"}'
-      values: '0 0 0 0 0'
-    - series: 'node_network_up{device="eth2",instance="node-exporter",
-      job="node-exporter"}'
-      values: '1 1 1 1 1'
-    - series: 'node_network_up{device="eth3",instance="node-exporter",
-      job="node-exporter"}'
-      values: '0 0 0 0 0'
-    - series: 'node_network_up{device="eth4",instance="node-exporter",
-      job="node-exporter"}'
-      values: '1 1 1 1 1'
-   promql_expr_test:
-     - expr: node_network_mtu_bytes{device!="lo"} * (node_network_up{device!="lo"} > 0) != on() group_left()
-             (quantile(0.5, node_network_mtu_bytes{device!="lo"}))
-       eval_time: 1m
-       exp_samples:
-         - labels: '{device="eth4", instance="node-exporter", job="node-exporter"}'
-           value: 9000
-   alert_rule_test:
-     - eval_time: 1m
-       alertname: MTU Mismatch
-       exp_alerts:
-       - exp_labels:
-           device: eth4
-           instance: node-exporter
-           job: node-exporter
-           oid: 1.3.6.1.4.1.50495.15.1.2.8.5
-           severity: warning
-           type: ceph_default
-         exp_annotations:
-           description: >
-               Node node-exporter has a different MTU size (9000)
-               than the median value on device eth4.
-
- # pool full
- - interval: 1m
-   input_series:
-    - series: 'ceph_pool_stored{instance="ceph:9283",job="ceph",pool_id="1"}'
-      values: '0 0 0 0 0 0 0 0 0'
-    - series: 'ceph_pool_stored{instance="ceph:9283",job="ceph",pool_id="2"}'
-      values: '1850 1850 1850 1850 1850 1850 1850'
-    - series: 'ceph_pool_stored{instance="ceph:9283",job="ceph",pool_id="3"}'
-      values: '900 900 23524 23524 23524 23524 23524 23524
-      23524'
-    - series: 'ceph_pool_max_avail{instance="ceph:9283",job="ceph",pool_id="1"}'
-      values: '106287063040 106287063040 106287063040 106287063040 106287063040
-      106287063040 106287063040'
-    - series: 'ceph_pool_max_avail{instance="ceph:9283",job="ceph",pool_id="2"}'
-      values: '106287063040 106287063040 106287063040 106287063040 106287063040
-      106287063040 106287063040'
-    - series: 'ceph_pool_max_avail{instance="ceph:9283",job="ceph",pool_id="3"}'
-      values: '37.5 37.5 37.5 37.5 37.5 37.5 37.5'
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name="device_health_metrics",pool_id="1"}'
-      values: '1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name=".rgw.root",pool_id="2"}'
-      values: '1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
-      name="default.rgw.log",pool_id="3"}'
-      values: '1 1 1 1 1 1 1 1 1'
-   promql_expr_test:
-     - expr: |
-         ceph_pool_stored / (ceph_pool_stored + ceph_pool_max_avail)
-         * on(pool_id) group_right ceph_pool_metadata * 100 > 90
-
-       eval_time: 1m
-       exp_samples:
-         - labels: '{instance="ceph:9283", job="ceph", name="default.rgw.log",
-           pool_id="3"}'
-           value: 9.6E+01
-   alert_rule_test:
-     - eval_time: 2m
-       alertname: pool full
-       exp_alerts:
-       - exp_labels:
-           instance: ceph:9283
-           job: ceph
-           name: default.rgw.log
-           oid: 1.3.6.1.4.1.50495.15.1.2.9.1
-           pool_id: 3
-           severity: critical
-           type: ceph_default
-         exp_annotations:
-           description: Pool default.rgw.log at 96% capacity.
-
- # slow OSD ops
- - interval : 1m
-   input_series:
-    - series: 'ceph_healthcheck_slow_ops{instance="ceph:9283",job="ceph"}'
-      values: '1+0x120'
-   promql_expr_test:
-     - expr: ceph_healthcheck_slow_ops > 0
-       eval_time: 1m
-       exp_samples:
-         - labels: '{__name__="ceph_healthcheck_slow_ops", instance="ceph:9283",
-           job="ceph"}'
-           value: 1
-   alert_rule_test:
-     - eval_time: 20m
-       alertname: Slow OSD Ops
-       exp_alerts:
-       - exp_labels:
-           instance: ceph:9283
-           job: ceph
-           severity: warning
-           type: ceph_default
-         exp_annotations:
-           documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#slow-ops
-           description: >
-             1 OSD requests are taking too long to process
-             (osd_op_complaint_time exceeded)
-
-# CEPHADM orchestrator alert triggers
- - interval: 30s
-   input_series:
-    - series: 'ceph_health_detail{name="UPGRADE_EXCEPTION"}'
-      values: '1+0x40'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="UPGRADE_EXCEPTION"} > 0
-       eval_time: 2m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="UPGRADE_EXCEPTION"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Cluster upgrade has failed
-    - eval_time: 5m
-      alertname: Cluster upgrade has failed
-      exp_alerts:
-      - exp_labels:
-          name: UPGRADE_EXCEPTION
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          description: >
-            The cephadm cluster upgrade process has failed. The cluster remains in
-            an undetermined state.
-
-            Please review the cephadm logs, to understand the nature of the issue
- - interval: 30s
-   input_series:
-    - series: 'ceph_health_detail{name="CEPHADM_FAILED_DAEMON"}'
-      values: '1+0x40'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="CEPHADM_FAILED_DAEMON"} > 0
-       eval_time: 2m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="CEPHADM_FAILED_DAEMON"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: A daemon managed by cephadm is down
-    - eval_time: 5m
-      alertname: A daemon managed by cephadm is down
-      exp_alerts:
-      - exp_labels:
-          name: CEPHADM_FAILED_DAEMON
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          description: >
-            A daemon managed by cephadm is no longer active. Determine, which
-            daemon is down with 'ceph health detail'. you may start daemons with
-            the 'ceph orch daemon start <daemon_id>'
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="CEPHADM_PAUSED"}'
-      values: '1 1 1 1 1 1 1 1 1'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="CEPHADM_PAUSED"} > 0
-       eval_time: 2m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="CEPHADM_PAUSED"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: cephadm management has been paused
-    - eval_time: 5m
-      alertname: cephadm management has been paused
-      exp_alerts:
-      - exp_labels:
-          name: CEPHADM_PAUSED
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/cephadm/operations/#cephadm-paused
-          description: >
-            Cluster management has been paused manually. This will prevent the
-            orchestrator from service management and reconciliation. If this is
-            not intentional, resume cephadm operations with 'ceph orch resume'
-# MDS
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="MDS_DAMAGE"}'
-      values: '1 1 1 1 1 1 1 1 1'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="MDS_DAMAGE"} > 0
-       eval_time: 2m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="MDS_DAMAGE"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Ceph Filesystem damage detected
-    - eval_time: 5m
-      alertname: Ceph Filesystem damage detected
-      exp_alerts:
-      - exp_labels:
-          name: MDS_DAMAGE
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/cephfs/health-messages/#cephfs-health-messages
-          description: >
-            The filesystems metadata has been corrupted. Data access
-            may be blocked.
-
-            Either analyse the output from the mds daemon admin socket, or
-            escalate to support
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="MDS_HEALTH_READ_ONLY"}'
-      values: '1 1 1 1 1 1 1 1 1'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="MDS_HEALTH_READ_ONLY"} > 0
-       eval_time: 2m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="MDS_HEALTH_READ_ONLY"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Ceph Filesystem switched to READ ONLY
-    - eval_time: 5m
-      alertname: Ceph Filesystem switched to READ ONLY
-      exp_alerts:
-      - exp_labels:
-          name: MDS_HEALTH_READ_ONLY
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/cephfs/health-messages/#cephfs-health-messages
-          description: >
-            The filesystem has switched to READ ONLY due to an unexpected
-            write error, when writing to the metadata pool
-
-            Either analyse the output from the mds daemon admin socket, or
-            escalate to support
-# MGR
- - interval: 1m
-   input_series:
-    - series: 'up{job="ceph", instance="ceph-mgr:9283"}'
-      values: '1+0x2 0+0x10'
-   promql_expr_test:
-     - expr: up{job="ceph"} == 0
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="up", job="ceph", instance="ceph-mgr:9283"}'
-           value: 0
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: mgr prometheus module is not active
-    - eval_time: 10m
-      alertname: mgr prometheus module is not active
-      exp_alerts:
-      - exp_labels:
-          instance: ceph-mgr:9283
-          job: ceph
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          description: >
-            The mgr/prometheus module at ceph-mgr:9283 is unreachable. This
-            could mean that the module has been disabled or the mgr itself is down.
-
-            Without the mgr/prometheus module metrics and alerts will no longer
-            function. Open a shell to ceph and use 'ceph -s' to to determine whether the
-            mgr is active. If the mgr is not active, restart it, otherwise you can check
-            the mgr/prometheus module is loaded with 'ceph mgr module ls'  and if it's
-            not listed as enabled, enable it with 'ceph mgr module enable prometheus'
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="RECENT_MGR_MODULE_CRASH"}'
-      values: '0+0x2 1+0x20'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="RECENT_MGR_MODULE_CRASH"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="RECENT_MGR_MODULE_CRASH"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: mgr module failure
-    - eval_time: 15m
-      alertname: mgr module failure
-      exp_alerts:
-      - exp_labels:
-          name: RECENT_MGR_MODULE_CRASH
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#recent-mgr-module-crash
-          description: >
-            One or more mgr modules have crashed and are yet to be acknowledged by the administrator. A
-            crashed module may impact functionality within the cluster. Use the 'ceph crash' commands to
-            investigate which module has failed, and archive it to acknowledge the failure.
-# MON
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="MON_DISK_CRIT"}'
-      values: '0+0x2 1+0x10'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.a", hostname="ceph-mon-a"}'
-      values: '1+0x13'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="MON_DISK_CRIT"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="MON_DISK_CRIT"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Ceph mon disk space critically low
-    - eval_time: 10m
-      alertname: Ceph mon disk space critically low
-      exp_alerts:
-      - exp_labels:
-          name: "MON_DISK_CRIT"
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-disk-crit
-          description: |
-            The free space available to a monitor's store is critically low (<5% by default).
-            You should increase the space available to the monitor(s). The
-            default location for the store sits under /var/lib/ceph. Your monitor hosts are;
-              - ceph-mon-a
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="MON_DISK_LOW"}'
-      values: '0+0x2 1+0x10'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.a", hostname="ceph-mon-a"}'
-      values: '1+0x13'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="MON_DISK_LOW"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="MON_DISK_LOW"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Ceph mon disk space running low
-    - eval_time: 10m
-      alertname: Ceph mon disk space running low
-      exp_alerts:
-      - exp_labels:
-          name: "MON_DISK_LOW"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-disk-low
-          description: |
-            The space available to a monitor's store is approaching full (>70% is the default).
-            You should increase the space available to the monitor store. The
-            default location for the store sits under /var/lib/ceph. Your monitor hosts are;
-              - ceph-mon-a
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="MON_CLOCK_SKEW"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="MON_CLOCK_SKEW"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="MON_CLOCK_SKEW"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Clock skew detected across Ceph Monitor daemons
-    - eval_time: 10m
-      alertname: Clock skew detected across Ceph Monitor daemons
-      exp_alerts:
-      - exp_labels:
-          name: "MON_CLOCK_SKEW"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-clock-skew
-          description: |
-            The ceph monitors rely on a consistent time reference to maintain
-            quorum and cluster consistency. This event indicates that at least
-            one of your mons is not sync'd correctly.
-
-            Review the cluster status with ceph -s. This will show which monitors
-            are affected. Check the time sync status on each monitor host.
-
-# Check 3 mons one down, quorum at risk
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="MON_DOWN"}'
-      values: '0+0x2 1+0x12'
-    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.a"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.b"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.c"}'
-      values: '1+0x2 0+0x12'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.a", hostname="ceph-mon-1"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.b", hostname="ceph-mon-2"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.c", hostname="ceph-mon-3"}'
-      values: '1+0x14'
-   promql_expr_test:
-     - expr: ((ceph_health_detail{name="MON_DOWN"} == 1) * on() (count(ceph_mon_quorum_status == 1) == bool (floor(count(ceph_mon_metadata) / 2) + 1))) == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Monitor down, quorum is at risk
-      # shouldn't fire
-    - eval_time: 10m
-      alertname: Monitor down, quorum is at risk
-      exp_alerts:
-      - exp_labels:
-          severity: critical
-          type: ceph_default
-          oid: 1.3.6.1.4.1.50495.15.1.2.3.1
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-down
-          description: |
-            Quorum requires a majority of monitors (x 2) to be active
-            Without quorum the cluster will become inoperable, affecting all connected clients and services.
-
-            The following monitors are down:
-              - mon.c on ceph-mon-3
-# check 5 mons, 1 down - warning only
- - interval: 1m
-   input_series:
-    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.a"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.b"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.c"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.d"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.e"}'
-      values: '1+0x2 0+0x12'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.a", hostname="ceph-mon-1"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.b", hostname="ceph-mon-2"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.c", hostname="ceph-mon-3"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.d", hostname="ceph-mon-4"}'
-      values: '1+0x14'
-    - series: 'ceph_mon_metadata{ceph_daemon="mon.e", hostname="ceph-mon-5"}'
-      values: '1+0x14'
-   promql_expr_test:
-     - expr: (count(ceph_mon_quorum_status == 0) <= (count(ceph_mon_metadata) - floor(count(ceph_mon_metadata) / 2) + 1))
-       eval_time: 3m
-       exp_samples:
-         - labels: '{}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Monitor down
-    - eval_time: 10m
-      alertname: Monitor down
-      exp_alerts:
-      - exp_labels:
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#mon-down
-          description: |
-            You have 1 monitor down.
-            Quorum is still intact, but the loss of further monitors will make your cluster inoperable.
-
-            The following monitors are down:
-              - mon.e on ceph-mon-5
-# Device Health
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="DEVICE_HEALTH"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="DEVICE_HEALTH"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="DEVICE_HEALTH"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Device failure predicted
-    - eval_time: 10m
-      alertname: Device failure predicted
-      exp_alerts:
-      - exp_labels:
-          name: "DEVICE_HEALTH"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#id2
-          description: |
-            The device health module has determined that one or more devices will fail
-            soon. To review the device states use 'ceph device ls'. To show a specific
-            device use 'ceph device info <dev id>'.
-
-            Mark the OSD as out (so data may migrate to other OSDs in the cluster). Once
-            the osd is empty remove and replace the OSD.
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="DEVICE_HEALTH_TOOMANY"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="DEVICE_HEALTH_TOOMANY"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="DEVICE_HEALTH_TOOMANY"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Too many devices predicted to fail
-    - eval_time: 10m
-      alertname: Too many devices predicted to fail
-      exp_alerts:
-      - exp_labels:
-          name: "DEVICE_HEALTH_TOOMANY"
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#device-health-toomany
-          description: |
-            The device health module has determined that the number of devices predicted to
-            fail can not be remediated automatically, since it would take too many osd's out of
-            the cluster, impacting performance and potentially availabililty. You should add new
-            OSDs to the cluster to allow data to be relocated to avoid the data integrity issues.
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="DEVICE_HEALTH_IN_USE"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="DEVICE_HEALTH_IN_USE"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="DEVICE_HEALTH_IN_USE"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Device failure predicted, but automatic drain is incomplete
-    - eval_time: 10m
-      alertname: Device failure predicted, but automatic drain is incomplete
-      exp_alerts:
-      - exp_labels:
-          name: "DEVICE_HEALTH_IN_USE"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#device-health-in-use
-          description: |
-            The device health module has determined that one or more devices will fail
-            soon, but the normal process of relocating the data on the device to other
-            OSDs in the cluster is blocked.
-
-            Check the the cluster has available freespace. It may be necessary to add
-            more disks to the cluster to allow the data from the failing device to
-            successfully migrate.
-# OSD
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="OSD_HOST_DOWN"}'
-      values: '0+0x2 1+0x10'
-    - series: 'ceph_osd_up{ceph_daemon="osd.0"}'
-      values: '1+0x2 0+0x10'
-    - series: 'ceph_osd_metadata{ceph_daemon="osd.0", hostname="ceph-osd-1"}'
-      values: '1+0x12'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="OSD_HOST_DOWN"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="OSD_HOST_DOWN"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSD Host is down
-    - eval_time: 10m
-      alertname: OSD Host is down
-      exp_alerts:
-      - exp_labels:
-          name: "OSD_HOST_DOWN"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          description: |
-            The following OSDs are down:
-            - ceph-osd-1 : osd.0
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="OSD_SLOW_PING_TIME_FRONT"}'
-      values: '0+0x2 1+0x20'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="OSD_SLOW_PING_TIME_FRONT"} == 0
-       eval_time: 1m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="OSD_SLOW_PING_TIME_FRONT"}'
-           value: 0
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSD hearbeats running slow (frontend)
-    - eval_time: 10m
-      alertname: OSD hearbeats running slow (frontend)
-      exp_alerts:
-      - exp_labels:
-          name: "OSD_SLOW_PING_TIME_FRONT"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          description: |
-            OSD heartbeats on the cluster's 'public' network (frontend) are running slow. Investigate the network
-            for any latency issues on this subnet. Use 'ceph health detail' to show the affected OSDs.
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="OSD_SLOW_PING_TIME_BACK"}'
-      values: '0+0x2 1+0x20'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="OSD_SLOW_PING_TIME_BACK"} == 0
-       eval_time: 1m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="OSD_SLOW_PING_TIME_BACK"}'
-           value: 0
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSD hearbeats running slow (backend)
-    - eval_time: 10m
-      alertname: OSD hearbeats running slow (backend)
-      exp_alerts:
-      - exp_labels:
-          name: "OSD_SLOW_PING_TIME_BACK"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          description: |
-            OSD heartbeats on the cluster's 'cluster' network (backend) are running slow. Investigate the network
-            for any latency issues on this subnet. Use 'ceph health detail' to show the affected OSDs.
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="BLUESTORE_DISK_SIZE_MISMATCH"}'
-      values: '0+0x2 1+0x20'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="BLUESTORE_DISK_SIZE_MISMATCH"} == 0
-       eval_time: 1m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="BLUESTORE_DISK_SIZE_MISMATCH"}'
-           value: 0
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSD disk size mismatch
-    - eval_time: 10m
-      alertname: OSD disk size mismatch
-      exp_alerts:
-      - exp_labels:
-          name: "BLUESTORE_DISK_SIZE_MISMATCH"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#bluestore-disk-size-mismatch
-          description: |
-            One or more OSDs have an internal inconsistency between the size of the physical device and it's metadata.
-            This could lead to the OSD(s) crashing in future. You should redeploy the effected OSDs.
- - interval: 30s
-   input_series:
-    - series: 'ceph_health_detail{name="BLUESTORE_SPURIOUS_READ_ERRORS"}'
-      values: '0+0x2 1+0x20'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="BLUESTORE_SPURIOUS_READ_ERRORS"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="BLUESTORE_SPURIOUS_READ_ERRORS"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSD Read errors
-    - eval_time: 10m
-      alertname: OSD Read errors
-      exp_alerts:
-      - exp_labels:
-          name: "BLUESTORE_SPURIOUS_READ_ERRORS"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#bluestore-spurious-read-errors
-          description: >
-            An OSD has encountered read errors, but the OSD has recovered by retrying
-            the reads. This may indicate an issue with the Hardware or Kernel.
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="OSD_DOWN"}'
-      values: '0+0x2 1+0x10'
-    - series: 'ceph_osd_up{ceph_daemon="osd.0"}'
-      values: '1+0x12'
-    - series: 'ceph_osd_up{ceph_daemon="osd.1"}'
-      values: '1+0x2 0+0x10'
-    - series: 'ceph_osd_up{ceph_daemon="osd.2"}'
-      values: '1+0x12'
-    - series: 'ceph_osd_metadata{ceph_daemon="osd.0", hostname="ceph-osd-1"}'
-      values: '1+0x12'
-    - series: 'ceph_osd_metadata{ceph_daemon="osd.1", hostname="ceph-osd-2"}'
-      values: '1+0x12'
-    - series: 'ceph_osd_metadata{ceph_daemon="osd.2", hostname="ceph-osd-3"}'
-      values: '1+0x12'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="OSD_DOWN"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="OSD_DOWN"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSD down
-    - eval_time: 10m
-      alertname: OSD down
-      exp_alerts:
-      - exp_labels:
-          name: "OSD_DOWN"
-          severity: warning
-          type: ceph_default
-          oid: 1.3.6.1.4.1.50495.15.1.2.4.2
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-down
-          description: |
-            1 OSD down for over 5mins.
-
-            The following OSD is down:
-              - osd.1 on ceph-osd-2
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="OSD_NEARFULL"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="OSD_NEARFULL"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="OSD_NEARFULL"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSDs near full
-    - eval_time: 10m
-      alertname: OSDs near full
-      exp_alerts:
-      - exp_labels:
-          name: "OSD_NEARFULL"
-          severity: warning
-          type: ceph_default
-          oid: 1.3.6.1.4.1.50495.15.1.2.4.3
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-nearfull
-          description: |
-            One or more OSDs have reached their NEARFULL threshold
-
-            Use 'ceph health detail' to identify which OSDs have reached this threshold.
-            To resolve, either add capacity to the cluster, or delete unwanted data
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="OSD_BACKFILLFULL"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="OSD_BACKFILLFULL"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="OSD_BACKFILLFULL"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSD unable to perform rebalance
-    - eval_time: 10m
-      alertname: OSD unable to perform rebalance
-      exp_alerts:
-      - exp_labels:
-          name: "OSD_BACKFILLFULL"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-backfillfull
-          description: |
-            An OSD has reached it's BACKFILL FULL threshold. This will prevent rebalance operations
-            completing for some pools. Check the current capacity utilisation with 'ceph df'
-
-            To resolve, either add capacity to the cluster, or delete unwanted data
- - interval: 30s
-   input_series:
-    - series: 'ceph_health_detail{name="OSD_TOO_MANY_REPAIRS"}'
-      values: '0+0x2 1+0x20'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="OSD_TOO_MANY_REPAIRS"} == 0
-       eval_time: 1m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="OSD_TOO_MANY_REPAIRS"}'
-           value: 0
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: OSD too many read repairs
-    - eval_time: 10m
-      alertname: OSD too many read repairs
-      exp_alerts:
-      - exp_labels:
-          name: "OSD_TOO_MANY_REPAIRS"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#osd-too-many-repairs
-          description: |
-            Reads from an OSD have used a secondary PG to return data to the client, indicating
-            a potential failing disk.
-# Pools
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="POOL_BACKFILLFULL"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="POOL_BACKFILLFULL"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="POOL_BACKFILLFULL"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Ceph pool is too full for recovery/rebalance
-    - eval_time: 5m
-      alertname: Ceph pool is too full for recovery/rebalance
-      exp_alerts:
-      - exp_labels:
-          name: "POOL_BACKFILLFULL"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          description: >
-            A pool is approaching it's near full threshold, which will
-            prevent rebalance operations from completing. You should
-            consider adding more capacity to the pool.
-
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="POOL_FULL"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="POOL_FULL"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="POOL_FULL"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Ceph pool is full - writes blocked
-    - eval_time: 10m
-      alertname: Ceph pool is full - writes blocked
-      exp_alerts:
-      - exp_labels:
-          name: "POOL_FULL"
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pool-full
-          description: |
-            A pool has reached it's MAX quota, or the OSDs supporting the pool
-            have reached their FULL threshold. Until this is resolved, writes to
-            the pool will be blocked.
-
-            Determine the affected pool with 'ceph df detail', for example looking
-            at QUOTA BYTES and STORED. Either increase the pools quota, or add
-            capacity to the cluster first then increase it's quota
-            (e.g. ceph osd pool set quota <pool_name> max_bytes <bytes>)
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="POOL_NEAR_FULL"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="POOL_NEAR_FULL"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="POOL_NEAR_FULL"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Ceph pool is approaching full
-    - eval_time: 10m
-      alertname: Ceph pool is approaching full
-      exp_alerts:
-      - exp_labels:
-          name: "POOL_NEAR_FULL"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          description: |
-            A pool has exceeeded it warning (percent full) threshold, or the OSDs
-            supporting the pool have reached their NEARFULL thresholds. Writes may
-            continue, but you are at risk of the pool going read only if more capacity
-            isn't made available.
-
-            Determine the affected pool with 'ceph df detail', for example looking
-            at QUOTA BYTES and STORED. Either increase the pools quota, or add
-            capacity to the cluster first then increase it's quota
-            (e.g. ceph osd pool set quota <pool_name> max_bytes <bytes>)
-
-# PGs
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="PG_NOT_SCRUBBED"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="PG_NOT_SCRUBBED"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="PG_NOT_SCRUBBED"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Placement Group(s) have not been scrubbed
-    - eval_time: 10m
-      alertname: Placement Group(s) have not been scrubbed
-      exp_alerts:
-      - exp_labels:
-          name: "PG_NOT_SCRUBBED"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-not-scrubbed
-          description: |
-            One or more PGs have not been scrubbed recently. The scrub process is a data integrity
-            feature, protectng against bit-rot. It checks that objects and their metadata (size and
-            attributes) match across object replicas. When PGs miss their scrub window, it may
-            indicate the scrub window is too small, or PGs were not in a 'clean' state during the
-            scrub window.
-
-            You can manually initiate a scrub with: ceph pg scrub <pgid>
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="PG_RECOVERY_FULL"}'
-      values: '0+0x2 1+0x20'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="PG_RECOVERY_FULL"} == 0
-       eval_time: 1m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="PG_RECOVERY_FULL"}'
-           value: 0
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Recovery at risk, cluster too full
-    - eval_time: 10m
-      alertname: Recovery at risk, cluster too full
-      exp_alerts:
-      - exp_labels:
-          name: "PG_RECOVERY_FULL"
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-recovery-full
-          description: >
-            Data redundancy may be reduced, or is at risk, since one or more OSDs are at or above their
-            'full' threshold. Add more capacity to the cluster, or delete unwanted data.
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="PG_BACKFILL_FULL"}'
-      values: '0+0x2 1+0x20'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="PG_BACKFILL_FULL"} == 0
-       eval_time: 1m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="PG_BACKFILL_FULL"}'
-           value: 0
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Cluster too full, automatic data recovery impaired
-    - eval_time: 10m
-      alertname: Cluster too full, automatic data recovery impaired
-      exp_alerts:
-      - exp_labels:
-          name: "PG_BACKFILL_FULL"
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-backfill-full
-          description: >
-            Data redundancy may be at risk due to lack of free space within the cluster. One or more OSDs
-            have breached their 'backfillfull' threshold. Add more capacity, or delete unwanted data.
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="PG_AVAILABILITY"}'
-      values: '0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_health_detail{name="OSD_DOWN"}'
-      values: '0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0'
-   promql_expr_test:
-     - expr: ((ceph_health_detail{name="PG_AVAILABILITY"} == 1) - scalar(ceph_health_detail{name="OSD_DOWN"}))
-       eval_time: 1m
-       # empty set at 1m
-       exp_samples:
-   alert_rule_test:
-    # PG_AVAILABILITY and OSD_DOWN not firing .. no alert
-    - eval_time: 1m
-      alertname: I/O blocked to some data
-      exp_alerts:
-    # PG_AVAILABILITY firing, but osd_down is active .. no alert
-    - eval_time: 5m
-      alertname: I/O blocked to some data
-      exp_alerts:
-    # PG_AVAILABILITY firing, AND OSD_DOWN is not active...raise the alert
-    - eval_time: 15m
-      alertname: I/O blocked to some data
-      exp_alerts:
-      - exp_labels:
-          name: "PG_AVAILABILITY"
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-availability
-          description: >
-            Data availability is reduced impacting the clusters abilty to service I/O to some data. One or
-            more placement groups (PGs) are in a state that blocks IO.
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="PG_NOT_DEEP_SCRUBBED"}'
-      values: '0+0x2 1+0x10'
-   promql_expr_test:
-     - expr: ceph_health_detail{name="PG_NOT_DEEP_SCRUBBED"} == 1
-       eval_time: 3m
-       exp_samples:
-         - labels: '{__name__="ceph_health_detail", name="PG_NOT_DEEP_SCRUBBED"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 1m
-      alertname: Placement Group(s) have not been 'DEEP' scrubbed
-    - eval_time: 10m
-      alertname: Placement Group(s) have not been 'DEEP' scrubbed
-      exp_alerts:
-      - exp_labels:
-          name: "PG_NOT_DEEP_SCRUBBED"
-          severity: warning
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#pg-not-deep-scrubbed
-          description: |
-            One or more PGs have not been deep scrubbed recently. Deep scrub is a data integrity
-            feature, protectng against bit-rot. It compares the contents of objects and their
-            replicas for inconsistency. When PGs miss their deep scrub window, it may indicate
-            that the window is too small or PGs were not in a 'clean' state during the deep-scrub
-            window.
-
-            You can manually initiate a deep scrub with: ceph pg deep-scrub <pgid>
-
-# Prometheus
- - interval: 1m
-   input_series:
-    - series: 'up{job="myjob"}'
-      values: '1+0x10'
-   promql_expr_test:
-     - expr: absent(up{job="ceph"})
-       eval_time: 1m
-       exp_samples:
-         - labels: '{job="ceph"}'
-           value: 1
-   alert_rule_test:
-    - eval_time: 5m
-      alertname: Scrape job is missing
-      exp_alerts:
-      - exp_labels:
-          job: ceph
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          description: |
-            The prometheus job that scrapes from Ceph is no longer defined, this
-            will effectively mean you'll have no metrics or alerts for the cluster.
-
-            Please review the job definitions in the prometheus.yml file of the prometheus
-            instance.
-# RADOS
- - interval: 1m
-   input_series:
-    - series: 'ceph_health_detail{name="OBJECT_UNFOUND"}'
-      values: '0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_osd_up{ceph_daemon="osd.0"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_osd_up{ceph_daemon="osd.1"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_osd_up{ceph_daemon="osd.2"}'
-      values: '1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_osd_metadata{ceph_daemon="osd.0"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_osd_metadata{ceph_daemon="osd.1"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-    - series: 'ceph_osd_metadata{ceph_daemon="osd.2"}'
-      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
-   promql_expr_test:
-     - expr: (ceph_health_detail{name="OBJECT_UNFOUND"} == 1) * on() (count(ceph_osd_up == 1) == bool count(ceph_osd_metadata)) == 1
-       eval_time: 1m
-       exp_samples:
-   alert_rule_test:
-    # OBJECT_UNFOUND but osd.2 is down, so don't fire
-    - eval_time: 5m
-      alertname: Data not found/missing
-      exp_alerts:
-    # OBJECT_UNFOUND and all osd's are online, so fire
-    - eval_time: 15m
-      alertname: Data not found/missing
-      exp_alerts:
-      - exp_labels:
-          severity: critical
-          type: ceph_default
-        exp_annotations:
-          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks/#object-unfound
-          description: |
-            A version of a RADOS object can not be found, even though all OSDs are up. I/O
-            requests for this object from clients will block (hang). Resolving this issue may
-            require the object to be rolled back to a prior version manually, and manually verified.
\ No newline at end of file
diff --git a/monitoring/prometheus/tests/README.md b/monitoring/prometheus/tests/README.md
new file mode 100644 (file)
index 0000000..cf95fa6
--- /dev/null
@@ -0,0 +1,92 @@
+
+## Alert Rule Standards
+
+The alert rules should adhere to the following principles
+- each alert must have a unique name
+- each alert should define a common structure
+  - labels : must contain severity and type
+  - annotations : must provide description
+  - expr : must define the promql expression 
+  - alert : defines the alert name 
+- alerts that have a corresponding section within docs.ceph.com must include a 
+  documentation field in the annotations section
+- critical alerts should declare an oid in the labels section
+- critical alerts should have a corresponding entry in the Ceph MIB
+
+&nbsp;
+## Testing Prometheus Rules
+Once you have updated the `ceph_default_alerts.yml` file, you should use the 
+`validate_rules.py` script directly, or via `tox` to ensure the format of any update 
+or change aligns to our rule structure guidelines. The validate_rules.py script will
+process the rules and look for any configuration anomalies and output a report if
+problems are detected.
+
+Here's an example run, to illustrate the format and the kinds of issues detected.
+
+```
+[paul@myhost tests]$ ./validate_rules.py 
+
+Checking rule groups
+        cluster health : ..
+        mon            : E.W..
+        osd            : E...W......W.E..
+        mds            : WW
+        mgr            : WW
+        pgs            : ..WWWW..
+        nodes          : .EEEE
+        pools          : EEEW.
+        healthchecks   : .
+        cephadm        : WW.
+        prometheus     : W
+        rados          : W
+
+Summary
+
+Rule file             : ../alerts/ceph_default_alerts.yml
+Unit Test file        : test_alerts.yml
+
+Rule groups processed :  12
+Rules processed       :  51
+Rule errors           :  10
+Rule warnings         :  16
+Rule name duplicates  :   0
+Unit tests missing    :   4
+
+Problem Report
+
+  Group       Severity  Alert Name                                          Problem Description
+  -----       --------  ----------                                          -------------------
+  cephadm     Warning   Cluster upgrade has failed                          critical level alert is missing an SNMP oid entry
+  cephadm     Warning   A daemon managed by cephadm is down                 critical level alert is missing an SNMP oid entry
+  mds         Warning   Ceph Filesystem damage detected                     critical level alert is missing an SNMP oid entry
+  mds         Warning   Ceph Filesystem switched to READ ONLY               critical level alert is missing an SNMP oid entry
+  mgr         Warning   mgr module failure                                  critical level alert is missing an SNMP oid entry
+  mgr         Warning   mgr prometheus module is not active                 critical level alert is missing an SNMP oid entry
+  mon         Error     Monitor down, quorum is at risk                     documentation link error: #mon-downwah not found on the page
+  mon         Warning   Ceph mon disk space critically low                  critical level alert is missing an SNMP oid entry
+  nodes       Error     network packets dropped                             invalid alert structure. Missing field: for
+  nodes       Error     network packet errors                               invalid alert structure. Missing field: for
+  nodes       Error     storage filling up                                  invalid alert structure. Missing field: for
+  nodes       Error     MTU Mismatch                                        invalid alert structure. Missing field: for
+  osd         Error     10% OSDs down                                       invalid alert structure. Missing field: for
+  osd         Error     Flapping OSD                                        invalid alert structure. Missing field: for
+  osd         Warning   OSD Full                                            critical level alert is missing an SNMP oid entry
+  osd         Warning   Too many devices predicted to fail                  critical level alert is missing an SNMP oid entry
+  pgs         Warning   Placement Group (PG) damaged                        critical level alert is missing an SNMP oid entry
+  pgs         Warning   Recovery at risk, cluster too full                  critical level alert is missing an SNMP oid entry
+  pgs         Warning   I/O blocked to some data                            critical level alert is missing an SNMP oid entry
+  pgs         Warning   Cluster too full, automatic data recovery impaired  critical level alert is missing an SNMP oid entry
+  pools       Error     pool full                                           invalid alert structure. Missing field: for
+  pools       Error     pool filling up (growth forecast)                   invalid alert structure. Missing field: for
+  pools       Error     Ceph pool is too full for recovery/rebalance        invalid alert structure. Missing field: for
+  pools       Warning   Ceph pool is full - writes blocked                  critical level alert is missing an SNMP oid entry
+  prometheus  Warning   Scrape job is missing                               critical level alert is missing an SNMP oid entry
+  rados       Warning   Data not found/missing                              critical level alert is missing an SNMP oid entry
+
+Unit tests are incomplete. Tests missing for the following alerts;
+  - Placement Group (PG) damaged
+  - OSD Full
+  - storage filling up
+  - pool filling up (growth forecast)
+
+```
diff --git a/monitoring/prometheus/tests/__init__.py b/monitoring/prometheus/tests/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/monitoring/prometheus/tests/requirements.txt b/monitoring/prometheus/tests/requirements.txt
new file mode 100644 (file)
index 0000000..bd25ccc
--- /dev/null
@@ -0,0 +1,2 @@
+pyyaml
+bs4
\ No newline at end of file
diff --git a/monitoring/prometheus/tests/settings.py b/monitoring/prometheus/tests/settings.py
new file mode 100644 (file)
index 0000000..c54f141
--- /dev/null
@@ -0,0 +1,2 @@
+ALERTS_FILE = '../alerts/ceph_default_alerts.yml'
+UNIT_TESTS_FILE = 'test_alerts.yml'
\ No newline at end of file
diff --git a/monitoring/prometheus/tests/test_alerts.yml b/monitoring/prometheus/tests/test_alerts.yml
new file mode 100644 (file)
index 0000000..ab423c9
--- /dev/null
@@ -0,0 +1,1806 @@
+rule_files:
+  - ../alerts/ceph_default_alerts.yml
+evaluation_interval: 5m
+tests:
+ # health error
+ - interval: 5m
+   input_series:
+    - series: 'ceph_health_status{instance="ceph:9283",job="ceph"}'
+      values: '2 2 2 2 2 2 2'
+   promql_expr_test:
+    - expr: ceph_health_status == 2
+      eval_time: 5m
+      exp_samples:
+       - labels: 'ceph_health_status{instance="ceph:9283",job="ceph"}'
+         value: 2
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: health error
+    - eval_time: 6m
+      alertname: health error
+      exp_alerts:
+      - exp_labels:
+          instance: ceph:9283
+          job: ceph
+          oid: 1.3.6.1.4.1.50495.15.1.2.2.1
+          type: ceph_default
+          severity: critical
+        exp_annotations:
+          description: >
+            Ceph in HEALTH_ERROR state for more than 5 minutes.
+            Please check "ceph health detail" for more information.
+
+ # health warning
+ - interval: 5m
+   input_series:
+    - series: 'ceph_health_status{instance="ceph:9283",job="ceph"}'
+      values: '1 1 1 1 1 1 1 1 1 1'
+   promql_expr_test:
+     - expr: ceph_health_status == 1
+       eval_time: 15m
+       exp_samples:
+         - labels: 'ceph_health_status{instance="ceph:9283",job="ceph"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 10m
+      alertname: health warn
+    - eval_time: 20m
+      alertname: health warn
+      exp_alerts:
+      - exp_labels:
+          instance: ceph:9283
+          job: ceph
+          oid: 1.3.6.1.4.1.50495.15.1.2.2.2
+          type: ceph_default
+          severity: warning
+        exp_annotations:
+          description: >
+            Ceph has been in HEALTH_WARN for more than 15 minutes.
+            Please check "ceph health detail" for more information.
+
+ # low monitor quorum count
+#  - interval: 1m
+#    input_series:
+#     - series: 'ceph_mon_quorum_status{ceph_daemon="mon.a",instance="ceph:9283",
+#       job="ceph"}'
+#       values: '1 1 1 1 1'
+#     - series: 'ceph_mon_quorum_status{ceph_daemon="mon.b",instance="ceph:9283",
+#       job="ceph"}'
+#       values: '1 1 1 1 1'
+#     - series: 'ceph_mon_quorum_status{ceph_daemon="mon.c",instance="ceph:9283",
+#       job="ceph"}'
+#       values: '0 0 0 0 0'
+#     - series: 'ceph_mon_metadata{ceph_daemon="mon.a",ceph_version="ceph version
+#       17.0.0-189-g3558fd72 (3558fd7291855971aa6481a2ade468ad61fbb346) pacific
+#       (dev)",hostname="ceph",instance="ceph:9283",job="ceph",
+#       public_addr="172.20.0.2",rank="0"}'
+#       values: '1 1 1 1 1'
+#     - series: 'ceph_mon_metadata{ceph_daemon="mon.b",ceph_version="ceph version
+#       17.0.0-189-g3558fd72 (3558fd7291855971aa6481a2ade468ad61fbb346) pacific
+#       (dev)",hostname="ceph",instance="ceph:9283",job="ceph",
+#       public_addr="172.20.0.2",rank="1"}'
+#       values: '1 1 1 1 1'
+#     - series: 'ceph_mon_metadata{ceph_daemon="mon.c",ceph_version="ceph version
+#       17.0.0-189-g3558fd72 (3558fd7291855971aa6481a2ade468ad61fbb346) pacific
+#       (dev)",hostname="ceph",instance="ceph:9283",job="ceph",
+#       public_addr="172.20.0.2",rank="2"}'
+#       values: '1 1 1 1 1'
+#    promql_expr_test:
+#      - expr: sum(ceph_mon_quorum_status) < 3
+#        eval_time: 1m
+#        exp_samples:
+#          - labels: '{}'
+#            value: 2
+#    alert_rule_test:
+#     - eval_time: 1m
+#       alertname: low monitor quorum count
+#       exp_alerts:
+#       - exp_labels:
+#           oid: 1.3.6.1.4.1.50495.15.1.2.3.1
+#           type: ceph_default
+#           severity: critical
+#         exp_annotations:
+#           description: |
+#             Monitor count in quorum is below three.
+
+#             Only 2 of 3 monitors are active.
+
+#             The following monitors are down:
+#               - mon.c on ceph
+
+
+ # 10% OSDs down
+ - interval: 1m
+   input_series:
+    - series: 'ceph_osd_up{ceph_daemon="osd.0",instance="ceph:9283",job="ceph"}'
+      values: '1 1 1 1 1'
+    - series: 'ceph_osd_up{ceph_daemon="osd.1",instance="ceph:9283",job="ceph"}'
+      values: '0 0 0 0 0'
+    - series: 'ceph_osd_up{ceph_daemon="osd.2",instance="ceph:9283",job="ceph"}'
+      values: '1 1 1 1 1'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1'
+   promql_expr_test:
+     - expr: count(ceph_osd_up == 0) / count(ceph_osd_up) * 100 >= 10
+       eval_time: 1m
+       exp_samples:
+         - labels: '{}'
+           value: 3.333333333333333E+01
+   alert_rule_test:
+     - eval_time: 1m
+       alertname: 10% OSDs down
+       exp_alerts:
+       - exp_labels:
+           oid: 1.3.6.1.4.1.50495.15.1.2.4.1
+           type: ceph_default
+           severity: critical
+         exp_annotations:
+           description: |
+             33.33% or 1 of 3 OSDs are down (≥ 10%).
+
+             The following OSDs are down:
+               - osd.1 on ceph
+
+ # OSD down
+#  - interval: 1m
+#    input_series:
+#     - series: 'ceph_osd_up{ceph_daemon="osd.0",instance="ceph:9283",job="ceph"}'
+#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+#     - series: 'ceph_osd_up{ceph_daemon="osd.1",instance="ceph:9283",job="ceph"}'
+#       values: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'
+#     - series: 'ceph_osd_up{ceph_daemon="osd.2",instance="ceph:9283",job="ceph"}'
+#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
+#       ceph_version="ceph version 17.0.0-189-g3558fd72
+#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+#       public_addr="172.20.0.2"}'
+#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
+#       ceph_version="ceph version 17.0.0-189-g3558fd72
+#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+#       public_addr="172.20.0.2"}'
+#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
+#       ceph_version="ceph version 17.0.0-189-g3558fd72
+#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+#       public_addr="172.20.0.2"}'
+#       values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+#    promql_expr_test:
+#      - expr: count(ceph_osd_up == 0) > 0
+#        eval_time: 1m
+#        exp_samples:
+#          - labels: '{}'
+#            value: 1
+#    alert_rule_test:
+#      - eval_time: 15m
+#        alertname: OSD down
+#        exp_alerts:
+#        - exp_labels:
+#            oid: 1.3.6.1.4.1.50495.15.1.2.4.2
+#            type: ceph_default
+#            severity: warning
+#          exp_annotations:
+#            description: |
+
+#              1 OSD down for more than 15 minutes.
+
+#              1 of 3 OSDs are down.
+
+#              The following OSD is down:
+#                  - osd.1 on ceph
+
+# OSDs near full
+#  - interval: 1m
+#    input_series:
+#     - series: 'ceph_osd_stat_bytes_used{ceph_daemon="osd.0",instance="ceph:9283"
+#       ,job="ceph"}'
+#       values: '1076310016 1076310016 1076310016 1076310016 1076310016
+#       1076310016'
+#     - series: 'ceph_osd_stat_bytes_used{ceph_daemon="osd.1",instance="ceph:9283"
+#       ,job="ceph"}'
+#       values: '1076310016 1076310016 1076310016 1076310016 1076310016
+#       1076310016'
+#     - series: 'ceph_osd_stat_bytes_used{ceph_daemon="osd.2",instance="ceph:9283"
+#       ,job="ceph"}'
+#       values: '1076310016 1076310016 1076310016 1076310016 1076310016
+#       100856561909.76'
+#     - series: 'ceph_osd_stat_bytes{ceph_daemon="osd.0",instance="ceph:9283"
+#       ,job="ceph"}'
+#       values: '108447916032 108447916032 108447916032 108447916032 108447916032
+#       108447916032'
+#     - series: 'ceph_osd_stat_bytes{ceph_daemon="osd.1",instance="ceph:9283"
+#       ,job="ceph"}'
+#       values: '108447916032 108447916032 108447916032 108447916032 108447916032
+#       108447916032'
+#     - series: 'ceph_osd_stat_bytes{ceph_daemon="osd.2",instance="ceph:9283"
+#       ,job="ceph"}'
+#       values: '108447916032 108447916032 108447916032 108447916032 108447916032
+#       108447916032'
+#     - series: 'ceph_osd_up{ceph_daemon="osd.0",instance="ceph:9283",job="ceph"}'
+#       values: '1 1 1 1 1 1'
+#     - series: 'ceph_osd_up{ceph_daemon="osd.1",instance="ceph:9283",job="ceph"}'
+#       values: '1 1 1 1 1 1'
+#     - series: 'ceph_osd_up{ceph_daemon="osd.2",instance="ceph:9283",job="ceph"}'
+#       values: '1 1 1 1 1 1'
+#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
+#       ceph_version="ceph version 17.0.0-189-g3558fd72
+#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+#       public_addr="172.20.0.2"}'
+#       values: '1 1 1 1 1 1'
+#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
+#       ceph_version="ceph version 17.0.0-189-g3558fd72
+#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+#       public_addr="172.20.0.2"}'
+#       values: '1 1 1 1 1 1'
+#     - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
+#       ceph_version="ceph version 17.0.0-189-g3558fd72
+#       (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+#       cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+#       hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+#       public_addr="172.20.0.2"}'
+#       values: '1 1 1 1 1 1'
+#    promql_expr_test:
+#      - expr: |
+#          (
+#            ((ceph_osd_stat_bytes_used / ceph_osd_stat_bytes) and on(ceph_daemon)
+#            ceph_osd_up == 1) * on(ceph_daemon) group_left(hostname)
+#            ceph_osd_metadata
+#          ) * 100 > 90
+
+#        eval_time: 5m
+#        exp_samples:
+#          - labels: '{ceph_daemon="osd.2",hostname="ceph",instance="ceph:9283",
+#            job="ceph"}'
+#            value: 9.3E+01
+#    alert_rule_test:
+#      - eval_time: 10m
+#        alertname: OSDs near full
+#        exp_alerts:
+#        - exp_labels:
+#            ceph_daemon: osd.2
+#            hostname: ceph
+#            instance: ceph:9283
+#            job: ceph
+#            oid: 1.3.6.1.4.1.50495.15.1.2.4.3
+#            type: ceph_default
+#            severity: critical
+#          exp_annotations:
+#            description: >
+#              OSD osd.2 on ceph is dangerously full: 93%
+
+ # flapping OSD
+ - interval: 1s
+   input_series:
+    - series: 'ceph_osd_up{ceph_daemon="osd.0",instance="ceph:9283",job="ceph"}'
+      values: '1+1x100'
+    - series: 'ceph_osd_up{ceph_daemon="osd.1",instance="ceph:9283",job="ceph"}'
+      values: '1+0x100'
+    - series: 'ceph_osd_up{ceph_daemon="osd.2",instance="ceph:9283",job="ceph"}'
+      values: '1+0x100'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1 1'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1 1'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1 1'
+   promql_expr_test:
+     - expr: |
+         (
+           rate(ceph_osd_up[5m])
+           * on(ceph_daemon) group_left(hostname) ceph_osd_metadata
+         ) * 60 > 1
+       eval_time: 1m
+       exp_samples:
+         - labels: '{ceph_daemon="osd.0", hostname="ceph", instance="ceph:9283",
+           job="ceph"}'
+           value: 1.2200000000000001E+01
+   alert_rule_test:
+     - eval_time: 5m
+       alertname: Flapping OSD
+       exp_alerts:
+       - exp_labels:
+           ceph_daemon: osd.0
+           hostname: ceph
+           instance: ceph:9283
+           job: ceph
+           oid: 1.3.6.1.4.1.50495.15.1.2.4.4
+           severity: warning
+           type: ceph_default
+         exp_annotations:
+           documentation: https://docs.ceph.com/en/latest/rados/troubleshooting/troubleshooting-osd#flapping-osds
+           description: >
+              OSD osd.0 on ceph was
+              marked down and back up at 20.1 times once a minute for 5 minutes.
+              This could indicate a network issue (latency, packet drop, disruption)
+              on the clusters "cluster network". Check the network environment on the
+              listed host(s).
+
+ # high pg count deviation
+ - interval: 1m
+   input_series:
+    - series: 'ceph_osd_numpg{ceph_daemon="osd.0",instance="ceph:9283",
+      job="ceph"}'
+      values: '100 100 100 100 100 160'
+    - series: 'ceph_osd_numpg{ceph_daemon="osd.1",instance="ceph:9283",
+      job="ceph"}'
+      values: '100 100 100 100 100 320'
+    - series: 'ceph_osd_numpg{ceph_daemon="osd.2",instance="ceph:9283",
+      job="ceph"}'
+      values: '100 100 100 100 100 160'
+    - series: 'ceph_osd_numpg{ceph_daemon="osd.3",instance="ceph:9283",
+      job="ceph"}'
+      values: '100 100 100 100 100 160'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.0",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1 1'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.1",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1 1'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.2",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1 1'
+    - series: 'ceph_osd_metadata{back_iface="eth0",ceph_daemon="osd.3",
+      ceph_version="ceph version 17.0.0-189-g3558fd72
+      (3558fd7291855971aa6481a2ade468ad61fbb346) pacific (dev)",
+      cluster_addr="172.20.0.2",device_class="hdd",front_iface="eth0",
+      hostname="ceph",instance="ceph:9283",job="ceph",objectstore="bluestore",
+      public_addr="172.20.0.2"}'
+      values: '1 1 1 1 1 1'
+   promql_expr_test:
+     - expr: |
+         abs(
+           (
+             (ceph_osd_numpg > 0) - on (job) group_left avg(ceph_osd_numpg > 0)
+             by (job)
+           ) / on (job) group_left avg(ceph_osd_numpg > 0) by (job)
+         ) * on(ceph_daemon) group_left(hostname) ceph_osd_metadata > 0.30
+
+       eval_time: 5m
+       exp_samples:
+         - labels: '{ceph_daemon="osd.1", hostname="ceph", instance="ceph:9283",
+           job="ceph"}'
+           value: 6E-01
+   alert_rule_test:
+     - eval_time: 10m
+       alertname: high pg count deviation
+       exp_alerts:
+       - exp_labels:
+           ceph_daemon: osd.1
+           hostname: ceph
+           instance: ceph:9283
+           job: ceph
+           oid: 1.3.6.1.4.1.50495.15.1.2.4.5
+           severity: warning
+           type: ceph_default
+         exp_annotations:
+           description: >
+              OSD osd.1 on ceph deviates
+              by more than 30% from average PG count.
+
+ # pgs inactive
+ - interval: 1m
+   input_series:
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name="device_health_metrics",pool_id="1"}'
+      values: '1 1 1 1 1 1 1 1'
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name="device_health_metrics",pool_id="2"}'
+      values: '1 1 1 1 1 1 1 1'
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name="device_health_metrics",pool_id="3"}'
+      values: '1 1 1 1 1 1 1 1'
+    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="1"}'
+      values: '1 1 1 1 1 1 1 1'
+    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="2"}'
+      values: '32 32 32 32 32 32 32 32'
+    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="3"}'
+      values: '33 32 32 32 32 33 33 32'
+    - series: 'ceph_pg_active{instance="ceph:9283",job="ceph",pool_id="1"}'
+      values: '1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_pg_active{instance="ceph:9283",job="ceph",pool_id="2"}'
+      values: '32 32 32 32 32 32 32 32'
+    - series: 'ceph_pg_active{instance="ceph:9283",job="ceph",pool_id="3"}'
+      values: '32 32 32 32 32 32 32 32'
+   promql_expr_test:
+     - expr: ceph_pool_metadata * on(pool_id,instance) group_left()
+             (ceph_pg_total - ceph_pg_active) > 0
+       eval_time: 5m
+       exp_samples:
+         - labels: '{instance="ceph:9283", job="ceph",
+           name="device_health_metrics",
+           pool_id="3"}'
+           value: 1
+   alert_rule_test:
+     - eval_time: 5m
+       alertname: pgs inactive
+       exp_alerts:
+       - exp_labels:
+           instance: ceph:9283
+           job: ceph
+           name: device_health_metrics
+           oid: 1.3.6.1.4.1.50495.15.1.2.7.1
+           pool_id: 3
+           severity: critical
+           type: ceph_default
+         exp_annotations:
+           description: >
+              1 PGs have been inactive for more than 5 minutes in pool
+              device_health_metrics.
+              Inactive placement groups aren't able to serve read/write
+              requests.
+
+ #pgs unclean
+ - interval: 1m
+   input_series:
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name="device_health_metrics",pool_id="1"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name="device_health_metrics",pool_id="2"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name="device_health_metrics",pool_id="3"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="1"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="2"}'
+      values: '32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
+      32 32 32'
+    - series: 'ceph_pg_total{instance="ceph:9283",job="ceph",pool_id="3"}'
+      values: '33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
+      33 33'
+    - series: 'ceph_pg_clean{instance="ceph:9283",job="ceph",pool_id="1"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_pg_clean{instance="ceph:9283",job="ceph",pool_id="2"}'
+      values: '32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
+      32 32'
+    - series: 'ceph_pg_clean{instance="ceph:9283",job="ceph",pool_id="3"}'
+      values: '32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
+      32 32'
+   promql_expr_test:
+     - expr: ceph_pool_metadata * on(pool_id,instance) group_left()
+             (ceph_pg_total - ceph_pg_clean) > 0
+       eval_time: 15m
+       exp_samples:
+         - labels: '{instance="ceph:9283", job="ceph",
+           name="device_health_metrics", pool_id="3"}'
+           value: 1
+   alert_rule_test:
+     - eval_time: 16m
+       alertname: pgs unclean
+       exp_alerts:
+       - exp_labels:
+           instance: ceph:9283
+           job: ceph
+           name: device_health_metrics
+           oid: 1.3.6.1.4.1.50495.15.1.2.7.2
+           pool_id: 3
+           severity: warning
+           type: ceph_default
+         exp_annotations:
+           description: >
+              1 PGs haven't been clean for more than 15 minutes in pool
+              device_health_metrics.
+              Unclean PGs haven't been able to completely recover from a
+              previous failure.
+
+ # root volume full
+ - interval: 1m
+   input_series:
+    - series: 'node_filesystem_avail_bytes{device="/dev/mapper/fedora_localhost
+      --live-home",fstype="ext4",instance="node-exporter",job="node-exporter",
+      mountpoint="/"}'
+      values: '35336400896 35336400896 35336400896 35336400896 35336400896
+      3525385519.104 3533640089'
+    - series: 'node_filesystem_size_bytes{device="/dev/mapper/fedora_localhost
+      --live-home",fstype="ext4",instance="node-exporter",job="node-exporter",
+      mountpoint="/"}'
+      values: '73445531648 73445531648 73445531648 73445531648 73445531648
+      73445531648 73445531648'
+   promql_expr_test:
+     - expr: node_filesystem_avail_bytes{mountpoint="/"} /
+             node_filesystem_size_bytes{mountpoint="/"} * 100 < 5
+       eval_time: 5m
+       exp_samples:
+         - labels: '{device="/dev/mapper/fedora_localhost --live-home",
+           fstype="ext4", instance="node-exporter", job="node-exporter",
+           mountpoint="/"}'
+           value: 4.8E+00
+   alert_rule_test:
+     - eval_time: 10m
+       alertname: root volume full
+       exp_alerts:
+       - exp_labels:
+           device: /dev/mapper/fedora_localhost --live-home
+           fstype: ext4
+           instance: node-exporter
+           job: node-exporter
+           mountpoint: /
+           oid: 1.3.6.1.4.1.50495.15.1.2.8.1
+           severity: critical
+           type: ceph_default
+         exp_annotations:
+           description: >
+              Root volume (OSD and MON store) is dangerously full: 4.811% free.
+
+ # network packets dropped
+ - interval: 1s
+   input_series:
+    - series: 'node_network_receive_drop_total{device="eth0",
+      instance="node-exporter",job="node-exporter"}'
+      values: '1+1x500'
+    - series: 'node_network_transmit_drop_total{device="eth0",
+      instance="node-exporter",job="node-exporter"}'
+      values: '1+1x500'
+   promql_expr_test:
+     - expr: |
+         (
+           increase(node_network_receive_drop_total{device!="lo"}[1m]) +
+           increase(node_network_transmit_drop_total{device!="lo"}[1m])
+         ) / (
+           increase(node_network_receive_packets_total{device!="lo"}[1m]) +
+           increase(node_network_transmit_packets_total{device!="lo"}[1m])
+         ) >= 0.0001 or (
+           increase(node_network_receive_drop_total{device!="lo"}[1m]) +
+           increase(node_network_transmit_drop_total{device!="lo"}[1m])
+         ) >= 10
+
+       eval_time: 5m
+       exp_samples:
+         - labels: '{device="eth0", instance="node-exporter",
+           job="node-exporter"}'
+           value: 1.2E+02
+   alert_rule_test:
+     - eval_time: 5m
+       alertname: network packets dropped
+       exp_alerts:
+       - exp_labels:
+           device: eth0
+           instance: node-exporter
+           job: node-exporter
+           oid: 1.3.6.1.4.1.50495.15.1.2.8.2
+           severity: warning
+           type: ceph_default
+         exp_annotations:
+           description: >
+              Node node-exporter experiences packet drop > 0.01% or >
+              10 packets/s on interface eth0.
+
+ # network packets errors
+ - interval: 1s
+   input_series:
+    - series: 'node_network_receive_errs_total{device="eth0",
+      instance="node-exporter",job="node-exporter"}'
+      values: '1+1x500'
+    - series: 'node_network_transmit_errs_total{device="eth0",
+      instance="node-exporter",job="node-exporter"}'
+      values: '1+1x500'
+   promql_expr_test:
+     - expr: |
+         (
+           increase(node_network_receive_errs_total{device!="lo"}[1m]) +
+           increase(node_network_transmit_errs_total{device!="lo"}[1m])
+         ) / (
+           increase(node_network_receive_packets_total{device!="lo"}[1m]) +
+           increase(node_network_transmit_packets_total{device!="lo"}[1m])
+         ) >= 0.0001 or (
+           increase(node_network_receive_errs_total{device!="lo"}[1m]) +
+           increase(node_network_transmit_errs_total{device!="lo"}[1m])
+         ) >= 10
+
+       eval_time: 5m
+       exp_samples:
+         - labels: '{device="eth0", instance="node-exporter",
+           job="node-exporter"}'
+           value: 1.2E+02
+   alert_rule_test:
+     - eval_time: 5m
+       alertname: network packet errors
+       exp_alerts:
+       - exp_labels:
+           device: eth0
+           instance: node-exporter
+           job: node-exporter
+           oid: 1.3.6.1.4.1.50495.15.1.2.8.3
+           severity: warning
+           type: ceph_default
+         exp_annotations:
+           description: >
+              Node node-exporter experiences packet errors > 0.01% or > 10
+              packets/s on interface eth0.
+
+ # MTU Mismatch
+ - interval: 1m
+   input_series:
+    - series: 'node_network_mtu_bytes{device="eth0",instance="node-exporter",
+      job="node-exporter"}'
+      values: '1500 1500 1500 1500 1500'
+    - series: 'node_network_mtu_bytes{device="eth1",instance="node-exporter",
+      job="node-exporter"}'
+      values: '1500 1500 1500 1500 1500'
+    - series: 'node_network_mtu_bytes{device="eth2",instance="node-exporter",
+      job="node-exporter"}'
+      values: '1500 1500 1500 1500 1500'
+    - series: 'node_network_mtu_bytes{device="eth3",instance="node-exporter",
+      job="node-exporter"}'
+      values: '1500 1500 1500 1500 1500'
+    - series: 'node_network_mtu_bytes{device="eth4",instance="node-exporter",
+      job="node-exporter"}'
+      values: '9000 9000 9000 9000 9000'
+    - series: 'node_network_up{device="eth0",instance="node-exporter",
+      job="node-exporter"}'
+      values: '0 0 0 0 0'
+    - series: 'node_network_up{device="eth1",instance="node-exporter",
+      job="node-exporter"}'
+      values: '0 0 0 0 0'
+    - series: 'node_network_up{device="eth2",instance="node-exporter",
+      job="node-exporter"}'
+      values: '1 1 1 1 1'
+    - series: 'node_network_up{device="eth3",instance="node-exporter",
+      job="node-exporter"}'
+      values: '0 0 0 0 0'
+    - series: 'node_network_up{device="eth4",instance="node-exporter",
+      job="node-exporter"}'
+      values: '1 1 1 1 1'
+   promql_expr_test:
+     - expr: node_network_mtu_bytes{device!="lo"} * (node_network_up{device!="lo"} > 0) != on() group_left()
+             (quantile(0.5, node_network_mtu_bytes{device!="lo"}))
+       eval_time: 1m
+       exp_samples:
+         - labels: '{device="eth4", instance="node-exporter", job="node-exporter"}'
+           value: 9000
+   alert_rule_test:
+     - eval_time: 1m
+       alertname: MTU Mismatch
+       exp_alerts:
+       - exp_labels:
+           device: eth4
+           instance: node-exporter
+           job: node-exporter
+           oid: 1.3.6.1.4.1.50495.15.1.2.8.5
+           severity: warning
+           type: ceph_default
+         exp_annotations:
+           description: >
+               Node node-exporter has a different MTU size (9000)
+               than the median value on device eth4.
+
+ # pool full
+ - interval: 1m
+   input_series:
+    - series: 'ceph_pool_stored{instance="ceph:9283",job="ceph",pool_id="1"}'
+      values: '0 0 0 0 0 0 0 0 0'
+    - series: 'ceph_pool_stored{instance="ceph:9283",job="ceph",pool_id="2"}'
+      values: '1850 1850 1850 1850 1850 1850 1850'
+    - series: 'ceph_pool_stored{instance="ceph:9283",job="ceph",pool_id="3"}'
+      values: '900 900 23524 23524 23524 23524 23524 23524
+      23524'
+    - series: 'ceph_pool_max_avail{instance="ceph:9283",job="ceph",pool_id="1"}'
+      values: '106287063040 106287063040 106287063040 106287063040 106287063040
+      106287063040 106287063040'
+    - series: 'ceph_pool_max_avail{instance="ceph:9283",job="ceph",pool_id="2"}'
+      values: '106287063040 106287063040 106287063040 106287063040 106287063040
+      106287063040 106287063040'
+    - series: 'ceph_pool_max_avail{instance="ceph:9283",job="ceph",pool_id="3"}'
+      values: '37.5 37.5 37.5 37.5 37.5 37.5 37.5'
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name="device_health_metrics",pool_id="1"}'
+      values: '1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name=".rgw.root",pool_id="2"}'
+      values: '1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_pool_metadata{instance="ceph:9283",job="ceph",
+      name="default.rgw.log",pool_id="3"}'
+      values: '1 1 1 1 1 1 1 1 1'
+   promql_expr_test:
+     - expr: |
+         ceph_pool_stored / (ceph_pool_stored + ceph_pool_max_avail)
+         * on(pool_id) group_right ceph_pool_metadata * 100 > 90
+
+       eval_time: 1m
+       exp_samples:
+         - labels: '{instance="ceph:9283", job="ceph", name="default.rgw.log",
+           pool_id="3"}'
+           value: 9.6E+01
+   alert_rule_test:
+     - eval_time: 2m
+       alertname: pool full
+       exp_alerts:
+       - exp_labels:
+           instance: ceph:9283
+           job: ceph
+           name: default.rgw.log
+           oid: 1.3.6.1.4.1.50495.15.1.2.9.1
+           pool_id: 3
+           severity: critical
+           type: ceph_default
+         exp_annotations:
+           description: Pool default.rgw.log at 96% capacity.
+
+ # slow OSD ops
+ - interval : 1m
+   input_series:
+    - series: 'ceph_healthcheck_slow_ops{instance="ceph:9283",job="ceph"}'
+      values: '1+0x120'
+   promql_expr_test:
+     - expr: ceph_healthcheck_slow_ops > 0
+       eval_time: 1m
+       exp_samples:
+         - labels: '{__name__="ceph_healthcheck_slow_ops", instance="ceph:9283",
+           job="ceph"}'
+           value: 1
+   alert_rule_test:
+     - eval_time: 20m
+       alertname: Slow OSD Ops
+       exp_alerts:
+       - exp_labels:
+           instance: ceph:9283
+           job: ceph
+           severity: warning
+           type: ceph_default
+         exp_annotations:
+           documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#slow-ops
+           description: >
+             1 OSD requests are taking too long to process
+             (osd_op_complaint_time exceeded)
+
+# CEPHADM orchestrator alert triggers
+ - interval: 30s
+   input_series:
+    - series: 'ceph_health_detail{name="UPGRADE_EXCEPTION"}'
+      values: '1+0x40'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="UPGRADE_EXCEPTION"} > 0
+       eval_time: 2m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="UPGRADE_EXCEPTION"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Cluster upgrade has failed
+    - eval_time: 5m
+      alertname: Cluster upgrade has failed
+      exp_alerts:
+      - exp_labels:
+          name: UPGRADE_EXCEPTION
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          description: >
+            The cephadm cluster upgrade process has failed. The cluster remains in
+            an undetermined state.
+
+            Please review the cephadm logs, to understand the nature of the issue
+ - interval: 30s
+   input_series:
+    - series: 'ceph_health_detail{name="CEPHADM_FAILED_DAEMON"}'
+      values: '1+0x40'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="CEPHADM_FAILED_DAEMON"} > 0
+       eval_time: 2m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="CEPHADM_FAILED_DAEMON"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: A daemon managed by cephadm is down
+    - eval_time: 5m
+      alertname: A daemon managed by cephadm is down
+      exp_alerts:
+      - exp_labels:
+          name: CEPHADM_FAILED_DAEMON
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          description: >
+            A daemon managed by cephadm is no longer active. Determine, which
+            daemon is down with 'ceph health detail'. you may start daemons with
+            the 'ceph orch daemon start <daemon_id>'
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="CEPHADM_PAUSED"}'
+      values: '1 1 1 1 1 1 1 1 1'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="CEPHADM_PAUSED"} > 0
+       eval_time: 2m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="CEPHADM_PAUSED"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: cephadm management has been paused
+    - eval_time: 5m
+      alertname: cephadm management has been paused
+      exp_alerts:
+      - exp_labels:
+          name: CEPHADM_PAUSED
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/cephadm/operations#cephadm-paused
+          description: >
+            Cluster management has been paused manually. This will prevent the
+            orchestrator from service management and reconciliation. If this is
+            not intentional, resume cephadm operations with 'ceph orch resume'
+# MDS
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="MDS_DAMAGE"}'
+      values: '1 1 1 1 1 1 1 1 1'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="MDS_DAMAGE"} > 0
+       eval_time: 2m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="MDS_DAMAGE"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Ceph Filesystem damage detected
+    - eval_time: 5m
+      alertname: Ceph Filesystem damage detected
+      exp_alerts:
+      - exp_labels:
+          name: MDS_DAMAGE
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/cephfs/health-messages#cephfs-health-messages
+          description: >
+            The filesystems metadata has been corrupted. Data access
+            may be blocked.
+
+            Either analyse the output from the mds daemon admin socket, or
+            escalate to support
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="MDS_HEALTH_READ_ONLY"}'
+      values: '1 1 1 1 1 1 1 1 1'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="MDS_HEALTH_READ_ONLY"} > 0
+       eval_time: 2m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="MDS_HEALTH_READ_ONLY"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Ceph Filesystem switched to READ ONLY
+    - eval_time: 5m
+      alertname: Ceph Filesystem switched to READ ONLY
+      exp_alerts:
+      - exp_labels:
+          name: MDS_HEALTH_READ_ONLY
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/cephfs/health-messages#cephfs-health-messages
+          description: >
+            The filesystem has switched to READ ONLY due to an unexpected
+            write error, when writing to the metadata pool
+
+            Either analyse the output from the mds daemon admin socket, or
+            escalate to support
+# MGR
+ - interval: 1m
+   input_series:
+    - series: 'up{job="ceph", instance="ceph-mgr:9283"}'
+      values: '1+0x2 0+0x10'
+   promql_expr_test:
+     - expr: up{job="ceph"} == 0
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="up", job="ceph", instance="ceph-mgr:9283"}'
+           value: 0
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: mgr prometheus module is not active
+    - eval_time: 10m
+      alertname: mgr prometheus module is not active
+      exp_alerts:
+      - exp_labels:
+          instance: ceph-mgr:9283
+          job: ceph
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          description: >
+            The mgr/prometheus module at ceph-mgr:9283 is unreachable. This
+            could mean that the module has been disabled or the mgr itself is down.
+
+            Without the mgr/prometheus module metrics and alerts will no longer
+            function. Open a shell to ceph and use 'ceph -s' to to determine whether the
+            mgr is active. If the mgr is not active, restart it, otherwise you can check
+            the mgr/prometheus module is loaded with 'ceph mgr module ls'  and if it's
+            not listed as enabled, enable it with 'ceph mgr module enable prometheus'
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="RECENT_MGR_MODULE_CRASH"}'
+      values: '0+0x2 1+0x20'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="RECENT_MGR_MODULE_CRASH"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="RECENT_MGR_MODULE_CRASH"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: mgr module failure
+    - eval_time: 15m
+      alertname: mgr module failure
+      exp_alerts:
+      - exp_labels:
+          name: RECENT_MGR_MODULE_CRASH
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#recent-mgr-module-crash
+          description: >
+            One or more mgr modules have crashed and are yet to be acknowledged by the administrator. A
+            crashed module may impact functionality within the cluster. Use the 'ceph crash' commands to
+            investigate which module has failed, and archive it to acknowledge the failure.
+# MON
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="MON_DISK_CRIT"}'
+      values: '0+0x2 1+0x10'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.a", hostname="ceph-mon-a"}'
+      values: '1+0x13'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="MON_DISK_CRIT"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="MON_DISK_CRIT"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Ceph mon disk space critically low
+    - eval_time: 10m
+      alertname: Ceph mon disk space critically low
+      exp_alerts:
+      - exp_labels:
+          name: "MON_DISK_CRIT"
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-disk-crit
+          description: |
+            The free space available to a monitor's store is critically low (<5% by default).
+            You should increase the space available to the monitor(s). The
+            default location for the store sits under /var/lib/ceph. Your monitor hosts are;
+              - ceph-mon-a
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="MON_DISK_LOW"}'
+      values: '0+0x2 1+0x10'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.a", hostname="ceph-mon-a"}'
+      values: '1+0x13'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="MON_DISK_LOW"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="MON_DISK_LOW"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Ceph mon disk space running low
+    - eval_time: 10m
+      alertname: Ceph mon disk space running low
+      exp_alerts:
+      - exp_labels:
+          name: "MON_DISK_LOW"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-disk-low
+          description: |
+            The space available to a monitor's store is approaching full (>70% is the default).
+            You should increase the space available to the monitor store. The
+            default location for the store sits under /var/lib/ceph. Your monitor hosts are;
+              - ceph-mon-a
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="MON_CLOCK_SKEW"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="MON_CLOCK_SKEW"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="MON_CLOCK_SKEW"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Clock skew detected across Ceph Monitor daemons
+    - eval_time: 10m
+      alertname: Clock skew detected across Ceph Monitor daemons
+      exp_alerts:
+      - exp_labels:
+          name: "MON_CLOCK_SKEW"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-clock-skew
+          description: |
+            The ceph monitors rely on a consistent time reference to maintain
+            quorum and cluster consistency. This event indicates that at least
+            one of your mons is not sync'd correctly.
+
+            Review the cluster status with ceph -s. This will show which monitors
+            are affected. Check the time sync status on each monitor host.
+
+# Check 3 mons one down, quorum at risk
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="MON_DOWN"}'
+      values: '0+0x2 1+0x12'
+    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.a"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.b"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.c"}'
+      values: '1+0x2 0+0x12'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.a", hostname="ceph-mon-1"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.b", hostname="ceph-mon-2"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.c", hostname="ceph-mon-3"}'
+      values: '1+0x14'
+   promql_expr_test:
+     - expr: ((ceph_health_detail{name="MON_DOWN"} == 1) * on() (count(ceph_mon_quorum_status == 1) == bool (floor(count(ceph_mon_metadata) / 2) + 1))) == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Monitor down, quorum is at risk
+      # shouldn't fire
+    - eval_time: 10m
+      alertname: Monitor down, quorum is at risk
+      exp_alerts:
+      - exp_labels:
+          severity: critical
+          type: ceph_default
+          oid: 1.3.6.1.4.1.50495.15.1.2.3.1
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-down
+          description: |
+            Quorum requires a majority of monitors (x 2) to be active
+            Without quorum the cluster will become inoperable, affecting all connected clients and services.
+
+            The following monitors are down:
+              - mon.c on ceph-mon-3
+# check 5 mons, 1 down - warning only
+ - interval: 1m
+   input_series:
+    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.a"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.b"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.c"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.d"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_quorum_status{ceph_daemon="mon.e"}'
+      values: '1+0x2 0+0x12'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.a", hostname="ceph-mon-1"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.b", hostname="ceph-mon-2"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.c", hostname="ceph-mon-3"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.d", hostname="ceph-mon-4"}'
+      values: '1+0x14'
+    - series: 'ceph_mon_metadata{ceph_daemon="mon.e", hostname="ceph-mon-5"}'
+      values: '1+0x14'
+   promql_expr_test:
+     - expr: (count(ceph_mon_quorum_status == 0) <= (count(ceph_mon_metadata) - floor(count(ceph_mon_metadata) / 2) + 1))
+       eval_time: 3m
+       exp_samples:
+         - labels: '{}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Monitor down
+    - eval_time: 10m
+      alertname: Monitor down
+      exp_alerts:
+      - exp_labels:
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#mon-down
+          description: |
+            You have 1 monitor down.
+            Quorum is still intact, but the loss of further monitors will make your cluster inoperable.
+
+            The following monitors are down:
+              - mon.e on ceph-mon-5
+# Device Health
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="DEVICE_HEALTH"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="DEVICE_HEALTH"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="DEVICE_HEALTH"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Device failure predicted
+    - eval_time: 10m
+      alertname: Device failure predicted
+      exp_alerts:
+      - exp_labels:
+          name: "DEVICE_HEALTH"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#id2
+          description: |
+            The device health module has determined that one or more devices will fail
+            soon. To review the device states use 'ceph device ls'. To show a specific
+            device use 'ceph device info <dev id>'.
+
+            Mark the OSD as out (so data may migrate to other OSDs in the cluster). Once
+            the osd is empty remove and replace the OSD.
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="DEVICE_HEALTH_TOOMANY"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="DEVICE_HEALTH_TOOMANY"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="DEVICE_HEALTH_TOOMANY"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Too many devices predicted to fail
+    - eval_time: 10m
+      alertname: Too many devices predicted to fail
+      exp_alerts:
+      - exp_labels:
+          name: "DEVICE_HEALTH_TOOMANY"
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#device-health-toomany
+          description: |
+            The device health module has determined that the number of devices predicted to
+            fail can not be remediated automatically, since it would take too many osd's out of
+            the cluster, impacting performance and potentially availabililty. You should add new
+            OSDs to the cluster to allow data to be relocated to avoid the data integrity issues.
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="DEVICE_HEALTH_IN_USE"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="DEVICE_HEALTH_IN_USE"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="DEVICE_HEALTH_IN_USE"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Device failure predicted, but automatic drain is incomplete
+    - eval_time: 10m
+      alertname: Device failure predicted, but automatic drain is incomplete
+      exp_alerts:
+      - exp_labels:
+          name: "DEVICE_HEALTH_IN_USE"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#device-health-in-use
+          description: |
+            The device health module has determined that one or more devices will fail
+            soon, but the normal process of relocating the data on the device to other
+            OSDs in the cluster is blocked.
+
+            Check the the cluster has available freespace. It may be necessary to add
+            more disks to the cluster to allow the data from the failing device to
+            successfully migrate.
+# OSD
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="OSD_HOST_DOWN"}'
+      values: '0+0x2 1+0x10'
+    - series: 'ceph_osd_up{ceph_daemon="osd.0"}'
+      values: '1+0x2 0+0x10'
+    - series: 'ceph_osd_metadata{ceph_daemon="osd.0", hostname="ceph-osd-1"}'
+      values: '1+0x12'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="OSD_HOST_DOWN"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="OSD_HOST_DOWN"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSD Host is down
+    - eval_time: 10m
+      alertname: OSD Host is down
+      exp_alerts:
+      - exp_labels:
+          name: "OSD_HOST_DOWN"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          description: |
+            The following OSDs are down:
+            - ceph-osd-1 : osd.0
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="OSD_SLOW_PING_TIME_FRONT"}'
+      values: '0+0x2 1+0x20'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="OSD_SLOW_PING_TIME_FRONT"} == 0
+       eval_time: 1m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="OSD_SLOW_PING_TIME_FRONT"}'
+           value: 0
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSD hearbeats running slow (frontend)
+    - eval_time: 10m
+      alertname: OSD hearbeats running slow (frontend)
+      exp_alerts:
+      - exp_labels:
+          name: "OSD_SLOW_PING_TIME_FRONT"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          description: |
+            OSD heartbeats on the cluster's 'public' network (frontend) are running slow. Investigate the network
+            for any latency issues on this subnet. Use 'ceph health detail' to show the affected OSDs.
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="OSD_SLOW_PING_TIME_BACK"}'
+      values: '0+0x2 1+0x20'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="OSD_SLOW_PING_TIME_BACK"} == 0
+       eval_time: 1m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="OSD_SLOW_PING_TIME_BACK"}'
+           value: 0
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSD hearbeats running slow (backend)
+    - eval_time: 10m
+      alertname: OSD hearbeats running slow (backend)
+      exp_alerts:
+      - exp_labels:
+          name: "OSD_SLOW_PING_TIME_BACK"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          description: |
+            OSD heartbeats on the cluster's 'cluster' network (backend) are running slow. Investigate the network
+            for any latency issues on this subnet. Use 'ceph health detail' to show the affected OSDs.
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="BLUESTORE_DISK_SIZE_MISMATCH"}'
+      values: '0+0x2 1+0x20'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="BLUESTORE_DISK_SIZE_MISMATCH"} == 0
+       eval_time: 1m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="BLUESTORE_DISK_SIZE_MISMATCH"}'
+           value: 0
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSD disk size mismatch
+    - eval_time: 10m
+      alertname: OSD disk size mismatch
+      exp_alerts:
+      - exp_labels:
+          name: "BLUESTORE_DISK_SIZE_MISMATCH"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#bluestore-disk-size-mismatch
+          description: |
+            One or more OSDs have an internal inconsistency between the size of the physical device and it's metadata.
+            This could lead to the OSD(s) crashing in future. You should redeploy the effected OSDs.
+ - interval: 30s
+   input_series:
+    - series: 'ceph_health_detail{name="BLUESTORE_SPURIOUS_READ_ERRORS"}'
+      values: '0+0x2 1+0x20'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="BLUESTORE_SPURIOUS_READ_ERRORS"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="BLUESTORE_SPURIOUS_READ_ERRORS"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSD Read errors
+    - eval_time: 10m
+      alertname: OSD Read errors
+      exp_alerts:
+      - exp_labels:
+          name: "BLUESTORE_SPURIOUS_READ_ERRORS"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#bluestore-spurious-read-errors
+          description: >
+            An OSD has encountered read errors, but the OSD has recovered by retrying
+            the reads. This may indicate an issue with the Hardware or Kernel.
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="OSD_DOWN"}'
+      values: '0+0x2 1+0x10'
+    - series: 'ceph_osd_up{ceph_daemon="osd.0"}'
+      values: '1+0x12'
+    - series: 'ceph_osd_up{ceph_daemon="osd.1"}'
+      values: '1+0x2 0+0x10'
+    - series: 'ceph_osd_up{ceph_daemon="osd.2"}'
+      values: '1+0x12'
+    - series: 'ceph_osd_metadata{ceph_daemon="osd.0", hostname="ceph-osd-1"}'
+      values: '1+0x12'
+    - series: 'ceph_osd_metadata{ceph_daemon="osd.1", hostname="ceph-osd-2"}'
+      values: '1+0x12'
+    - series: 'ceph_osd_metadata{ceph_daemon="osd.2", hostname="ceph-osd-3"}'
+      values: '1+0x12'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="OSD_DOWN"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="OSD_DOWN"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSD down
+    - eval_time: 10m
+      alertname: OSD down
+      exp_alerts:
+      - exp_labels:
+          name: "OSD_DOWN"
+          severity: warning
+          type: ceph_default
+          oid: 1.3.6.1.4.1.50495.15.1.2.4.2
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-down
+          description: |
+            1 OSD down for over 5mins.
+
+            The following OSD is down:
+              - osd.1 on ceph-osd-2
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="OSD_NEARFULL"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="OSD_NEARFULL"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="OSD_NEARFULL"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSDs near full
+    - eval_time: 10m
+      alertname: OSDs near full
+      exp_alerts:
+      - exp_labels:
+          name: "OSD_NEARFULL"
+          severity: warning
+          type: ceph_default
+          oid: 1.3.6.1.4.1.50495.15.1.2.4.3
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-nearfull
+          description: |
+            One or more OSDs have reached their NEARFULL threshold
+
+            Use 'ceph health detail' to identify which OSDs have reached this threshold.
+            To resolve, either add capacity to the cluster, or delete unwanted data
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="OSD_BACKFILLFULL"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="OSD_BACKFILLFULL"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="OSD_BACKFILLFULL"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSD unable to perform rebalance
+    - eval_time: 10m
+      alertname: OSD unable to perform rebalance
+      exp_alerts:
+      - exp_labels:
+          name: "OSD_BACKFILLFULL"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-backfillfull
+          description: |
+            An OSD has reached it's BACKFILL FULL threshold. This will prevent rebalance operations
+            completing for some pools. Check the current capacity utilisation with 'ceph df'
+
+            To resolve, either add capacity to the cluster, or delete unwanted data
+ - interval: 30s
+   input_series:
+    - series: 'ceph_health_detail{name="OSD_TOO_MANY_REPAIRS"}'
+      values: '0+0x2 1+0x20'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="OSD_TOO_MANY_REPAIRS"} == 0
+       eval_time: 1m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="OSD_TOO_MANY_REPAIRS"}'
+           value: 0
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: OSD too many read repairs
+    - eval_time: 10m
+      alertname: OSD too many read repairs
+      exp_alerts:
+      - exp_labels:
+          name: "OSD_TOO_MANY_REPAIRS"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#osd-too-many-repairs
+          description: |
+            Reads from an OSD have used a secondary PG to return data to the client, indicating
+            a potential failing disk.
+# Pools
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="POOL_BACKFILLFULL"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="POOL_BACKFILLFULL"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="POOL_BACKFILLFULL"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Ceph pool is too full for recovery/rebalance
+    - eval_time: 5m
+      alertname: Ceph pool is too full for recovery/rebalance
+      exp_alerts:
+      - exp_labels:
+          name: "POOL_BACKFILLFULL"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          description: >
+            A pool is approaching it's near full threshold, which will
+            prevent rebalance operations from completing. You should
+            consider adding more capacity to the pool.
+
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="POOL_FULL"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="POOL_FULL"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="POOL_FULL"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Ceph pool is full - writes blocked
+    - eval_time: 10m
+      alertname: Ceph pool is full - writes blocked
+      exp_alerts:
+      - exp_labels:
+          name: "POOL_FULL"
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pool-full
+          description: |
+            A pool has reached it's MAX quota, or the OSDs supporting the pool
+            have reached their FULL threshold. Until this is resolved, writes to
+            the pool will be blocked.
+
+            Determine the affected pool with 'ceph df detail', for example looking
+            at QUOTA BYTES and STORED. Either increase the pools quota, or add
+            capacity to the cluster first then increase it's quota
+            (e.g. ceph osd pool set quota <pool_name> max_bytes <bytes>)
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="POOL_NEAR_FULL"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="POOL_NEAR_FULL"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="POOL_NEAR_FULL"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Ceph pool is approaching full
+    - eval_time: 10m
+      alertname: Ceph pool is approaching full
+      exp_alerts:
+      - exp_labels:
+          name: "POOL_NEAR_FULL"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          description: |
+            A pool has exceeeded it warning (percent full) threshold, or the OSDs
+            supporting the pool have reached their NEARFULL thresholds. Writes may
+            continue, but you are at risk of the pool going read only if more capacity
+            isn't made available.
+
+            Determine the affected pool with 'ceph df detail', for example looking
+            at QUOTA BYTES and STORED. Either increase the pools quota, or add
+            capacity to the cluster first then increase it's quota
+            (e.g. ceph osd pool set quota <pool_name> max_bytes <bytes>)
+
+# PGs
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="PG_NOT_SCRUBBED"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="PG_NOT_SCRUBBED"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="PG_NOT_SCRUBBED"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Placement Group(s) have not been scrubbed
+    - eval_time: 10m
+      alertname: Placement Group(s) have not been scrubbed
+      exp_alerts:
+      - exp_labels:
+          name: "PG_NOT_SCRUBBED"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-not-scrubbed
+          description: |
+            One or more PGs have not been scrubbed recently. The scrub process is a data integrity
+            feature, protectng against bit-rot. It checks that objects and their metadata (size and
+            attributes) match across object replicas. When PGs miss their scrub window, it may
+            indicate the scrub window is too small, or PGs were not in a 'clean' state during the
+            scrub window.
+
+            You can manually initiate a scrub with: ceph pg scrub <pgid>
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="PG_RECOVERY_FULL"}'
+      values: '0+0x2 1+0x20'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="PG_RECOVERY_FULL"} == 0
+       eval_time: 1m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="PG_RECOVERY_FULL"}'
+           value: 0
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Recovery at risk, cluster too full
+    - eval_time: 10m
+      alertname: Recovery at risk, cluster too full
+      exp_alerts:
+      - exp_labels:
+          name: "PG_RECOVERY_FULL"
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-recovery-full
+          description: >
+            Data redundancy may be reduced, or is at risk, since one or more OSDs are at or above their
+            'full' threshold. Add more capacity to the cluster, or delete unwanted data.
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="PG_BACKFILL_FULL"}'
+      values: '0+0x2 1+0x20'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="PG_BACKFILL_FULL"} == 0
+       eval_time: 1m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="PG_BACKFILL_FULL"}'
+           value: 0
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Cluster too full, automatic data recovery impaired
+    - eval_time: 10m
+      alertname: Cluster too full, automatic data recovery impaired
+      exp_alerts:
+      - exp_labels:
+          name: "PG_BACKFILL_FULL"
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-backfill-full
+          description: >
+            Data redundancy may be at risk due to lack of free space within the cluster. One or more OSDs
+            have breached their 'backfillfull' threshold. Add more capacity, or delete unwanted data.
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="PG_AVAILABILITY"}'
+      values: '0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_health_detail{name="OSD_DOWN"}'
+      values: '0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0'
+   promql_expr_test:
+     - expr: ((ceph_health_detail{name="PG_AVAILABILITY"} == 1) - scalar(ceph_health_detail{name="OSD_DOWN"}))
+       eval_time: 1m
+       # empty set at 1m
+       exp_samples:
+   alert_rule_test:
+    # PG_AVAILABILITY and OSD_DOWN not firing .. no alert
+    - eval_time: 1m
+      alertname: I/O blocked to some data
+      exp_alerts:
+    # PG_AVAILABILITY firing, but osd_down is active .. no alert
+    - eval_time: 5m
+      alertname: I/O blocked to some data
+      exp_alerts:
+    # PG_AVAILABILITY firing, AND OSD_DOWN is not active...raise the alert
+    - eval_time: 15m
+      alertname: I/O blocked to some data
+      exp_alerts:
+      - exp_labels:
+          name: "PG_AVAILABILITY"
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-availability
+          description: >
+            Data availability is reduced impacting the clusters abilty to service I/O to some data. One or
+            more placement groups (PGs) are in a state that blocks IO.
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="PG_NOT_DEEP_SCRUBBED"}'
+      values: '0+0x2 1+0x10'
+   promql_expr_test:
+     - expr: ceph_health_detail{name="PG_NOT_DEEP_SCRUBBED"} == 1
+       eval_time: 3m
+       exp_samples:
+         - labels: '{__name__="ceph_health_detail", name="PG_NOT_DEEP_SCRUBBED"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 1m
+      alertname: Placement Group(s) have not been 'DEEP' scrubbed
+    - eval_time: 10m
+      alertname: Placement Group(s) have not been 'DEEP' scrubbed
+      exp_alerts:
+      - exp_labels:
+          name: "PG_NOT_DEEP_SCRUBBED"
+          severity: warning
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#pg-not-deep-scrubbed
+          description: |
+            One or more PGs have not been deep scrubbed recently. Deep scrub is a data integrity
+            feature, protectng against bit-rot. It compares the contents of objects and their
+            replicas for inconsistency. When PGs miss their deep scrub window, it may indicate
+            that the window is too small or PGs were not in a 'clean' state during the deep-scrub
+            window.
+
+            You can manually initiate a deep scrub with: ceph pg deep-scrub <pgid>
+
+# Prometheus
+ - interval: 1m
+   input_series:
+    - series: 'up{job="myjob"}'
+      values: '1+0x10'
+   promql_expr_test:
+     - expr: absent(up{job="ceph"})
+       eval_time: 1m
+       exp_samples:
+         - labels: '{job="ceph"}'
+           value: 1
+   alert_rule_test:
+    - eval_time: 5m
+      alertname: Scrape job is missing
+      exp_alerts:
+      - exp_labels:
+          job: ceph
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          description: |
+            The prometheus job that scrapes from Ceph is no longer defined, this
+            will effectively mean you'll have no metrics or alerts for the cluster.
+
+            Please review the job definitions in the prometheus.yml file of the prometheus
+            instance.
+# RADOS
+ - interval: 1m
+   input_series:
+    - series: 'ceph_health_detail{name="OBJECT_UNFOUND"}'
+      values: '0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_osd_up{ceph_daemon="osd.0"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_osd_up{ceph_daemon="osd.1"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_osd_up{ceph_daemon="osd.2"}'
+      values: '1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_osd_metadata{ceph_daemon="osd.0"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_osd_metadata{ceph_daemon="osd.1"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+    - series: 'ceph_osd_metadata{ceph_daemon="osd.2"}'
+      values: '1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
+   promql_expr_test:
+     - expr: (ceph_health_detail{name="OBJECT_UNFOUND"} == 1) * on() (count(ceph_osd_up == 1) == bool count(ceph_osd_metadata)) == 1
+       eval_time: 1m
+       exp_samples:
+   alert_rule_test:
+    # OBJECT_UNFOUND but osd.2 is down, so don't fire
+    - eval_time: 5m
+      alertname: Data not found/missing
+      exp_alerts:
+    # OBJECT_UNFOUND and all osd's are online, so fire
+    - eval_time: 15m
+      alertname: Data not found/missing
+      exp_alerts:
+      - exp_labels:
+          severity: critical
+          type: ceph_default
+        exp_annotations:
+          documentation: https://docs.ceph.com/en/latest/rados/operations/health-checks#object-unfound
+          description: |
+            A version of a RADOS object can not be found, even though all OSDs are up. I/O
+            requests for this object from clients will block (hang). Resolving this issue may
+            require the object to be rolled back to a prior version manually, and manually verified.
\ No newline at end of file
diff --git a/monitoring/prometheus/tests/test_syntax.py b/monitoring/prometheus/tests/test_syntax.py
new file mode 100755 (executable)
index 0000000..966d768
--- /dev/null
@@ -0,0 +1,42 @@
+import pytest
+import os
+import yaml
+from .utils import promtool_available, call
+from .settings import ALERTS_FILE, UNIT_TESTS_FILE
+
+
+def load_yaml(file_name):
+    yaml_data = None
+    with open(file_name, 'r') as alert_file:
+        raw = alert_file.read()
+        try:
+            yaml_data = yaml.safe_load(raw)
+        except yaml.YAMLError as e:
+            pass
+
+    return yaml_data
+
+
+def test_alerts_present():
+    assert os.path.exists(ALERTS_FILE), f"{ALERTS_FILE} not found"
+
+
+def test_unittests_present():
+    assert os.path.exists(UNIT_TESTS_FILE), f"{UNIT_TESTS_FILE} not found"
+
+
+@pytest.mark.skipif(not os.path.exists(ALERTS_FILE), reason=f"{ALERTS_FILE} missing")
+def test_rules_format():
+    assert load_yaml(ALERTS_FILE)
+
+
+@pytest.mark.skipif(not os.path.exists(UNIT_TESTS_FILE), reason=f"{UNIT_TESTS_FILE} missing")
+def test_unittests_format():
+    assert load_yaml(UNIT_TESTS_FILE)
+
+
+@pytest.mark.skipif(not promtool_available(), reason="promtool is not installed. Unable to check syntax")
+def test_rule_syntax():
+    completion = call(f"promtool check rules {ALERTS_FILE}")
+    assert completion.returncode == 0
+    assert b"SUCCESS" in completion.stdout
diff --git a/monitoring/prometheus/tests/test_unittests.py b/monitoring/prometheus/tests/test_unittests.py
new file mode 100644 (file)
index 0000000..4cfb2b6
--- /dev/null
@@ -0,0 +1,19 @@
+import pytest
+import os
+from .utils import promtool_available, call
+from .settings import ALERTS_FILE, UNIT_TESTS_FILE
+
+
+def test_alerts_present():
+    assert os.path.exists(ALERTS_FILE), f"{ALERTS_FILE} not found"
+
+
+def test_unittests_present():
+    assert os.path.exists(UNIT_TESTS_FILE), f"{UNIT_TESTS_FILE} not found"
+
+
+@pytest.mark.skipif(not promtool_available(), reason="promtool is not installed. Unable to run unit tests")
+def test_run_unittests():
+    completion = call(f"promtool test rules {UNIT_TESTS_FILE}")
+    assert completion.returncode == 0
+    assert b"SUCCESS" in completion.stdout
diff --git a/monitoring/prometheus/tests/tox.ini b/monitoring/prometheus/tests/tox.ini
new file mode 100644 (file)
index 0000000..8adde12
--- /dev/null
@@ -0,0 +1,11 @@
+[tox]
+envlist = py36
+skipsdist = true
+
+[testenv]
+deps =
+    -rrequirements.txt
+    pytest
+commands =
+    pytest -rA test_syntax.py test_unittests.py
+    ./validate_rules.py
diff --git a/monitoring/prometheus/tests/utils.py b/monitoring/prometheus/tests/utils.py
new file mode 100644 (file)
index 0000000..8429244
--- /dev/null
@@ -0,0 +1,12 @@
+import pytest
+import shutil
+import subprocess
+
+
+def promtool_available() -> bool:
+    return shutil.which('promtool') is not None
+
+
+def call(cmd):
+    completion = subprocess.run(cmd.split(), stdout=subprocess.PIPE)
+    return completion
diff --git a/monitoring/prometheus/tests/validate_rules.py b/monitoring/prometheus/tests/validate_rules.py
new file mode 100755 (executable)
index 0000000..b424533
--- /dev/null
@@ -0,0 +1,486 @@
+#!/usr/bin/python3 -u
+#
+# Check the Prometheus rules for format, and integration
+# with the unit tests. This script has the following exit
+# codes:
+#  0 .. Everything worked
+#  4 .. rule problems or missing unit tests
+#  8 .. Missing fields in YAML
+# 12 .. Invalid YAML - unable to load
+# 16 .. Missing input files
+
+# TODO: logging for debug
+
+import re
+import os
+import sys
+import yaml
+from bs4 import BeautifulSoup
+from typing import List, Any, Dict, Set, Optional, Tuple
+
+import urllib.request
+import urllib.error
+from urllib.parse import urlparse
+
+DOCLINK_NAME = 'documentation'
+DEFAULT_RULES_FILENAME = '../alerts/ceph_default_alerts.yml'
+DEFAULT_TEST_FILENAME = 'test_alerts.yml'
+
+
+def read_file(file_name: str) -> Tuple[str, str]:
+    try:
+        with open(file_name, 'r') as input_file:
+            raw_data = input_file.read()
+    except OSError:
+        return '', f"Unable to open {file_name}"
+
+    return raw_data, ''
+
+
+def load_yaml(file_name: str) -> Tuple[Dict[str, Any], str]:
+    data = {}
+    errs = ''
+
+    raw_data, err = read_file(file_name)
+    if not err:
+
+        try:
+            data = yaml.safe_load(raw_data)
+        except yaml.YAMLError as e:
+            errs = f"filename '{file_name} is not a valid YAML file"
+
+    return data, errs
+
+
+class HTMLCache:
+    def __init__(self) -> None:
+        self.cache: Dict[str, Tuple[int, str]] = {}
+
+    def fetch(self, url_str: str) -> None:
+        parsed = urlparse(url_str)
+        url = f"{parsed.scheme}://{parsed.netloc}{parsed.path}"
+
+        if url in self.cache:
+            return self.cache[url]
+
+        req = urllib.request.Request(url)
+        try:
+            r = urllib.request.urlopen(req)
+        except urllib.error.HTTPError as e:
+            self.cache[url] = e.code, e.reason
+            return self.cache[url]
+        except urllib.error.URLError as e:
+            self.cache[url] = 400, e.reason
+            return self.cache[url]
+
+        if r.status == 200:
+            html = r.read().decode('utf-8')
+            self.cache[url] = 200, html
+            return self.cache[url]
+
+        self.cache[url] = r.status, r.reason
+        return r.status, r.reason
+
+    @property
+    def cached_pages(self) -> List[str]:
+        return self.cache.keys()
+
+    @property
+    def cached_pages_total(self) -> int:
+        return len(self.cache.keys())
+
+class PrometheusRule:
+    expected_attrs = [
+        'alert',
+        'expr',
+        'for',
+        'labels',
+        'annotations'
+    ]
+
+    def __init__(self, rule_group, rule_data: Dict[str, Any]):
+
+        assert 'alert' in rule_data
+        self.group: RuleGroup = rule_group
+        self.name = rule_data.get('alert')
+        self.rule = rule_data
+        self.errors: List[str] = []
+        self.warnings: List[str] = []
+
+        self.validate()
+
+    def _check_alert_name(self):
+        pass
+
+    def _check_structure(self):
+        rule_attrs = self.rule.keys()
+        missing_attrs = [a for a in PrometheusRule.expected_attrs if a not in rule_attrs]
+
+        if missing_attrs:
+            self.errors.append(
+                f"invalid alert structure. Missing field{'s' if len(missing_attrs) > 1 else ''}"
+                f": {','.join(missing_attrs)}")
+
+    def _check_labels(self):
+        for rqd in ['severity', 'type']:
+            if rqd not in self.rule.get('labels', ''):
+                self.errors.append(f"rule is missing {rqd} label definition")
+
+    def _check_annotations(self):
+        for rqd in ['description']:
+                if rqd not in self.rule.get('annotations', ''):
+                    self.errors.append(f"rule is missing {rqd} annotation definition")
+
+    def _check_doclink(self):
+        annotations = self.rule.get('annotations', {})
+        doclink = annotations.get(DOCLINK_NAME, '')
+
+        if doclink:
+            url = urlparse(doclink)
+            status, content = self.group.fetch_html_page(doclink)
+            if status == 200:
+                if url.fragment:
+                    soup = BeautifulSoup(content, 'html.parser')
+                    if not soup.find(id=url.fragment):
+                        self.errors.append(f"documentation link error: {url.fragment} anchor not found on the page")
+            else:
+                # catch all
+                self.errors.append(f"documentation link error: {status} {content}")
+
+    def _check_snmp(self):
+        labels = self.rule.get('labels', {})
+        oid = labels.get('oid', '')
+        if labels.get('severity', '') == 'critical' and not oid:
+            self.warnings.append("critical level alert is missing an SNMP oid entry")
+        if oid and not re.search('^1.3.6.1.4.1.50495.15.1.2.\\d+.\\d+$', oid):
+            self.errors.append("invalid OID provided")
+
+    def validate(self):
+        self._check_alert_name()
+        self._check_structure()
+        self._check_labels()
+        self._check_annotations()
+        self._check_doclink()
+        self._check_snmp()
+        char = '.'
+
+        if self.errors:
+            char = 'E'
+            self.group.update('error', self.name)
+        elif self.warnings:
+            char = 'W'
+            self.group.update('warning', self.name)
+
+        sys.stdout.write(char)
+
+
+class RuleGroup:
+
+    def __init__(self, rule_file, group_name: str, group_name_width: int):
+        self.rule_file: RuleFile = rule_file
+        self.group_name = group_name
+        self.rules: Dict[str, PrometheusRule] = {}
+        self.problems = {
+            "error": [],
+            "warning": [],
+        }
+
+        sys.stdout.write(f"\n\t{group_name:<{group_name_width}} : ")
+
+    def add_rule(self, rule_data:Dict[str, Any]):
+        alert_name = rule_data.get('alert')
+        self.rules[alert_name] = PrometheusRule(self, rule_data)
+
+    def update(self, problem_type:str, alert_name:str):
+        assert problem_type in ['error', 'warning']
+
+        self.problems[problem_type].append(alert_name)
+        self.rule_file.update(self.group_name)
+
+    def fetch_html_page(self, url):
+        return self.rule_file.fetch_html_page(url)
+
+    @property
+    def error_count(self):
+        return len(self.problems['error'])
+
+    def warning_count(self):
+        return len(self.problems['warning'])
+
+    @property
+    def count(self):
+        return len(self.rules)
+
+
+class RuleFile:
+
+    def __init__(self, parent, file_name, rules):
+        self.parent = parent
+        self.file_name = file_name
+        self.rules: Dict[str, Any] = rules
+        self.problems: Set[str] = set()
+        self.group: Dict[str, RuleGroup] = {}
+        self.alert_names_seen: Set[str] = set()
+        self.duplicate_alert_names:List[str] = []
+        self.html_cache = HTMLCache()
+
+        assert 'groups' in self.rules
+        self.max_group_name_width = self.get_max_group_name()
+        self.load_groups()
+
+    def update(self, group_name):
+        self.problems.add(group_name)
+        self.parent.mark_invalid()
+
+    def fetch_html_page(self, url):
+        return self.html_cache.fetch(url)
+
+    @property
+    def group_count(self):
+        return len(self.rules['groups'])
+
+    @property
+    def rule_count(self):
+        rule_count = 0
+        for group_name, rule_group in self.group.items():
+            rule_count += rule_group.count
+        return rule_count
+
+    @property
+    def group_names(self):
+        return self.group.keys()
+
+    @property
+    def problem_count(self):
+        return len(self.problems)
+
+    def get_max_group_name(self):
+        group_name_list = []
+        for group in self.rules.get('groups'):
+            group_name_list.append(group['name'])
+        return max([len(g) for g in group_name_list])
+
+    def load_groups(self):
+        sys.stdout.write("\nChecking rule groups")
+        for group in self.rules.get('groups'):
+            group_name = group['name']
+            rules = group['rules']
+            self.group[group_name] = RuleGroup(self, group_name, self.max_group_name_width)
+            for rule_data in rules:
+                if 'alert' in rule_data:
+                    alert_name = rule_data.get('alert')
+                    if alert_name in self.alert_names_seen:
+                        self.duplicate_alert_names.append(alert_name)
+                    else:
+                        self.alert_names_seen.add(alert_name)
+                    self.group[group_name].add_rule(rule_data)
+                else:
+                    # skipped recording rule
+                    pass
+
+    def error_report(self):
+        def max_width(item_list: List[str]) -> int:
+            return max([len(i) for i in item_list])
+
+        if not self.problems and not self.duplicate_alert_names:
+            print("\nNo problems detected in rule file")
+            return
+
+        print("\nProblem Report\n")
+
+        group_width = max_width(self.problems)
+        alert_names = set()
+        for g in self.problems:
+            group = self.group[g]
+            alert_names.update(group.problems.get('error', []))
+            alert_names.update(group.problems.get('warning', []))
+        alert_width = max_width(alert_names)
+
+        template = "  {group:<{group_width}}  {severity:<8}  {alert_name:<{alert_width}}  {description}"
+
+        print(template.format(
+            group="Group",
+            group_width=group_width,
+            severity="Severity",
+            alert_name="Alert Name",
+            alert_width=alert_width,
+            description="Problem Description"))
+
+        print(template.format(
+            group="-----",
+            group_width=group_width,
+            severity="--------",
+            alert_name="----------",
+            alert_width=alert_width,
+            description="-------------------"))
+
+        for group_name in sorted(self.problems):
+            group = self.group[group_name]
+            rules = group.rules
+            for alert_name in group.problems.get('error', []):
+                for desc in rules[alert_name].errors:
+                    print(template.format(
+                            group=group_name,
+                            group_width=group_width,
+                            severity="Error",
+                            alert_name=alert_name,
+                            alert_width=alert_width,
+                            description=desc))
+            for alert_name in group.problems.get('warning', []):
+                for desc in rules[alert_name].warnings:
+                    print(template.format(
+                            group=group_name,
+                            group_width=group_width,
+                            severity="Warning",
+                            alert_name=alert_name,
+                            alert_width=alert_width,
+                            description=desc))
+        if self.duplicate_alert_names:
+            print("Duplicate alert names detected:")
+            for a in self.duplicate_alert_names:
+                print(f"  - {a}")
+
+
+class UnitTests:
+    expected_attrs = [
+        'rule_files',
+        'tests',
+        'evaluation_interval'
+    ]
+    def __init__(self, filename):
+        self.filename = filename
+        self.unit_test_data: Dict[str, Any] = {}
+        self.alert_names_seen: Set[str] = set()
+        self.problems: List[str] = []
+        self.load()
+
+    def load(self):
+        self.unit_test_data, errs = load_yaml(self.filename)
+        if errs:
+            print(f"\n\nError in unit tests file: {errs}")
+            sys.exit(12)
+
+        missing_attr = [a for a in UnitTests.expected_attrs if a not in self.unit_test_data.keys()]
+        if missing_attr:
+            print(f"\nMissing attributes in unit tests: {','.join(missing_attr)}")
+            sys.exit(8)
+
+    def _check_alert_names(self, alert_names: List[str]):
+        alerts_tested: Set[str] = set()
+        for t in self.unit_test_data.get('tests'):
+            test_cases = t.get('alert_rule_test', [])
+            if not test_cases:
+                continue
+            for case in test_cases:
+                alertname = case.get('alertname', '')
+                if alertname:
+                    alerts_tested.add(alertname)
+
+        alerts_defined = set(alert_names)
+        self.problems = list(alerts_defined.difference(alerts_tested))
+
+    def process(self, defined_alert_names: List[str]):
+        self._check_alert_names(defined_alert_names)
+
+    def error_report(self) -> None:
+
+        if not self.problems:
+            print("\nNo problems detected in unit tests file")
+            return
+
+        print("\nUnit tests are incomplete. Tests missing for the following alerts;")
+        for p in self.problems:
+            print(f"  - {p}")
+
+class RuleChecker:
+
+    def __init__(self, rules_filename: str = None, test_filename: str = None):
+        self.rules_filename = rules_filename or DEFAULT_RULES_FILENAME
+        self.test_filename = test_filename or DEFAULT_TEST_FILENAME
+        self.rule_file: Optional[RuleFile] = None
+        self.unit_tests: Optional[UnitTests] = None
+        self.rule_file_problems: bool = False
+        self.errors = {}
+        self.warnings = {}
+        self.error_count = 0
+        self.warning_count = 0
+
+    @property
+    def status(self):
+        if self.rule_file_problems or self.unit_tests.problems:
+            return 4
+
+        return 0
+
+    def mark_invalid(self):
+        self.rule_file_problems = True
+
+    def summarise_rule_file(self):
+        for group_name in self.rule_file.problems:
+            group = self.rule_file.group[group_name]
+            self.error_count += len(group.problems['error'])
+            self.warning_count += len(group.problems['warning'])
+
+    def ready(self):
+        errs: List[str] = []
+        ready_state = True
+        if not os.path.exists(self.rules_filename):
+            errs.append(f"rule file '{self.rules_filename}' not found")
+            ready_state = False
+
+        if not os.path.exists(self.test_filename):
+            errs.append(f"test file '{self.test_filename}' not found")
+            ready_state = False
+
+        return ready_state, errs
+
+    def run(self):
+
+        ready, errs = self.ready()
+        if not ready:
+            print("Unable to start:")
+            for e in errs:
+                print(f"- {e}")
+            sys.exit(16)
+
+        rules, errs = load_yaml(self.rules_filename)
+        if errs:
+            print(errs)
+            sys.exit(12)
+
+        self.rule_file = RuleFile(self, self.rules_filename, rules)
+        self.summarise_rule_file()
+
+        self.unit_tests = UnitTests(self.test_filename)
+        self.unit_tests.process(self.rule_file.alert_names_seen)
+
+    def error_report(self):
+        print("\n\nSummary\n")
+        print(f"Rule file             : {self.rules_filename}")
+        print(f"Unit Test file        : {self.test_filename}")
+        print(f"\nRule groups processed : {self.rule_file.group_count:>3}")
+        print(f"Rules processed       : {self.rule_file.rule_count:>3}")
+        print(f"Rule errors           : {self.error_count:>3}")
+        print(f"Rule warnings         : {self.warning_count:>3}")
+        print(f"Rule name duplicates  : {len(self.rule_file.duplicate_alert_names):>3}")
+        print(f"Unit tests missing    : {len(self.unit_tests.problems):>3}")
+
+        if self.rule_file_problems:
+            self.rule_file.error_report()
+        if self.unit_tests.problems:
+            self.unit_tests.error_report()
+
+
+def main():
+    checker = RuleChecker()
+
+    checker.run()
+    if checker.status > 0:
+        checker.error_report()
+        print()
+
+    sys.exit(checker.status)
+
+
+if __name__ == '__main__':
+    main()