From 1d1dda995cb325657dfe79014222a9b5f9756ab8 Mon Sep 17 00:00:00 2001 From: Vitaly Zhuravlev Date: Thu, 16 Nov 2023 13:34:35 +0000 Subject: [PATCH] Move alerts to sep file --- docs/macos-observ-lib/alerts.libsonnet | 23 +++++++++++++++++++++++ docs/macos-observ-lib/main.libsonnet | 19 ++----------------- 2 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 docs/macos-observ-lib/alerts.libsonnet diff --git a/docs/macos-observ-lib/alerts.libsonnet b/docs/macos-observ-lib/alerts.libsonnet new file mode 100644 index 0000000000..88714f8d96 --- /dev/null +++ b/docs/macos-observ-lib/alerts.libsonnet @@ -0,0 +1,23 @@ +{ + new(this, parentPrometheus): + { + groups: + //keep only alerts listed in alertsMacKeep + std.filter( + function(group) std.length(group.rules) > 0, + [ + { + name: group.name, + rules: [ + rule + for rule in group.rules + if std.length(std.find(rule.alert, this.config.alertsMacKeep)) > 0 + ], + } + for group in parentPrometheus.alerts.groups + ], + + ), + + }, +} diff --git a/docs/macos-observ-lib/main.libsonnet b/docs/macos-observ-lib/main.libsonnet index 2ea8ae04eb..b4f2bd3070 100644 --- a/docs/macos-observ-lib/main.libsonnet +++ b/docs/macos-observ-lib/main.libsonnet @@ -1,3 +1,4 @@ +local alerts = import './alerts.libsonnet'; local config = import './config.libsonnet'; local g = import './g.libsonnet'; local panels = import './panels.libsonnet'; @@ -48,23 +49,7 @@ nodelib }, prometheus+: { recordingRules: {}, - alerts: - { - groups: - [ - { - name: group.name, - rules: [ - rule - for rule in group.rules - if std.length(std.find(rule.alert, this.config.alertsMacKeep)) > 0 - ], - } - for group in parentPrometheus.alerts.groups - ], - - }, - + alerts: alerts.new(this, parentPrometheus), }, },