diff --git a/component/common.libsonnet b/component/common.libsonnet index 0c29b54..8cd61e4 100644 --- a/component/common.libsonnet +++ b/component/common.libsonnet @@ -77,6 +77,18 @@ local removeNamespace = { }, }; +local resetAlertManagerConfig = { + alertmanager+:: { + config+:: { + receivers: [], + inhibit_rules: [], + route+: { + routes: [], + }, + }, + }, +}; + local stackForInstance = function(instanceName) local confWithBase = com.makeMergeable(params.base) + com.makeMergeable(params.instances[instanceName]); local cm = std.foldl(function(prev, k) prev { @@ -95,7 +107,7 @@ local stackForInstance = function(instanceName) // We need to explicitly handle enabling thanos, as upstream has a "null" in the field, making standard merge impossible [if std.objectHas(confWithBase.prometheus.config, 'thanos') then 'thanos']: confWithBase.prometheus.config.thanos, }, - } + com.makeMergeable(cm), + } + resetAlertManagerConfig + com.makeMergeable(cm), } + com.makeMergeable(overrides) + removeNamespace; local render_component(configuredStack, component, prefix, instance) = diff --git a/tests/golden/kubernetes_1.20/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml b/tests/golden/kubernetes_1.20/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml index 3337941..6c1e9c4 100644 --- a/tests/golden/kubernetes_1.20/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml +++ b/tests/golden/kubernetes_1.20/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml @@ -14,14 +14,7 @@ metadata: namespace: syn-prometheus stringData: alertmanager.yaml: "\"global\":\n \"resolve_timeout\": \"5m\"\n\"inhibit_rules\"\ - :\n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_match\":\n \ - \ \"severity\": \"critical\"\n \"target_match_re\":\n \"severity\": \"warning|info\"\ - \n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_match\":\n \ - \ \"severity\": \"warning\"\n \"target_match_re\":\n \"severity\": \"info\"\ - \n\"receivers\":\n- \"name\": \"Default\"\n- \"name\": \"Watchdog\"\n- \"name\"\ - : \"Critical\"\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"group_interval\"\ - : \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\n \"repeat_interval\"\ - : \"12h\"\n \"routes\":\n - \"match\":\n \"alertname\": \"Watchdog\"\n\ - \ \"receiver\": \"Watchdog\"\n - \"match\":\n \"severity\": \"critical\"\ - \n \"receiver\": \"Critical\"" + : []\n\"receivers\": []\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"\ + group_interval\": \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\ + \n \"repeat_interval\": \"12h\"\n \"routes\": []" type: Opaque diff --git a/tests/golden/kubernetes_1.21/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml b/tests/golden/kubernetes_1.21/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml index 4d6ceac..a245460 100644 --- a/tests/golden/kubernetes_1.21/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml +++ b/tests/golden/kubernetes_1.21/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml @@ -14,14 +14,7 @@ metadata: namespace: syn-prometheus stringData: alertmanager.yaml: "\"global\":\n \"resolve_timeout\": \"5m\"\n\"inhibit_rules\"\ - :\n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_match\":\n \ - \ \"severity\": \"critical\"\n \"target_match_re\":\n \"severity\": \"warning|info\"\ - \n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_match\":\n \ - \ \"severity\": \"warning\"\n \"target_match_re\":\n \"severity\": \"info\"\ - \n\"receivers\":\n- \"name\": \"Default\"\n- \"name\": \"Watchdog\"\n- \"name\"\ - : \"Critical\"\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"group_interval\"\ - : \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\n \"repeat_interval\"\ - : \"12h\"\n \"routes\":\n - \"match\":\n \"alertname\": \"Watchdog\"\n\ - \ \"receiver\": \"Watchdog\"\n - \"match\":\n \"severity\": \"critical\"\ - \n \"receiver\": \"Critical\"" + : []\n\"receivers\": []\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"\ + group_interval\": \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\ + \n \"repeat_interval\": \"12h\"\n \"routes\": []" type: Opaque diff --git a/tests/golden/kubernetes_1.22/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml b/tests/golden/kubernetes_1.22/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml index 7454e58..b03a3f6 100644 --- a/tests/golden/kubernetes_1.22/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml +++ b/tests/golden/kubernetes_1.22/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml @@ -14,14 +14,7 @@ metadata: namespace: syn-prometheus stringData: alertmanager.yaml: "\"global\":\n \"resolve_timeout\": \"5m\"\n\"inhibit_rules\"\ - :\n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_matchers\":\n\ - \ - \"severity = critical\"\n \"target_matchers\":\n - \"severity =~ warning|info\"\ - \n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_matchers\":\n\ - \ - \"severity = warning\"\n \"target_matchers\":\n - \"severity = info\"\n\ - \"receivers\":\n- \"name\": \"Default\"\n- \"name\": \"Watchdog\"\n- \"name\"\ - : \"Critical\"\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"group_interval\"\ - : \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\n \"repeat_interval\"\ - : \"12h\"\n \"routes\":\n - \"matchers\":\n - \"alertname = Watchdog\"\n\ - \ \"receiver\": \"Watchdog\"\n - \"matchers\":\n - \"severity = critical\"\ - \n \"receiver\": \"Critical\"" + : []\n\"receivers\": []\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"\ + group_interval\": \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\ + \n \"repeat_interval\": \"12h\"\n \"routes\": []" type: Opaque diff --git a/tests/golden/kubernetes_1.23/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml b/tests/golden/kubernetes_1.23/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml index 4128211..a961b19 100644 --- a/tests/golden/kubernetes_1.23/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml +++ b/tests/golden/kubernetes_1.23/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml @@ -14,17 +14,7 @@ metadata: namespace: syn-prometheus stringData: alertmanager.yaml: "\"global\":\n \"resolve_timeout\": \"5m\"\n\"inhibit_rules\"\ - :\n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_matchers\":\n\ - \ - \"severity = critical\"\n \"target_matchers\":\n - \"severity =~ warning|info\"\ - \n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_matchers\":\n\ - \ - \"severity = warning\"\n \"target_matchers\":\n - \"severity = info\"\n\ - - \"equal\":\n - \"namespace\"\n \"source_matchers\":\n - \"alertname = InfoInhibitor\"\ - \n \"target_matchers\":\n - \"severity = info\"\n\"receivers\":\n- \"name\"\ - : \"Default\"\n- \"name\": \"Watchdog\"\n- \"name\": \"Critical\"\n- \"name\"\ - : \"null\"\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"group_interval\"\ - : \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\n \"repeat_interval\"\ - : \"12h\"\n \"routes\":\n - \"matchers\":\n - \"alertname = Watchdog\"\n\ - \ \"receiver\": \"Watchdog\"\n - \"matchers\":\n - \"alertname = InfoInhibitor\"\ - \n \"receiver\": \"null\"\n - \"matchers\":\n - \"severity = critical\"\ - \n \"receiver\": \"Critical\"" + : []\n\"receivers\": []\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"\ + group_interval\": \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\ + \n \"repeat_interval\": \"12h\"\n \"routes\": []" type: Opaque diff --git a/tests/golden/kubernetes_1.24/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml b/tests/golden/kubernetes_1.24/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml index 4128211..a961b19 100644 --- a/tests/golden/kubernetes_1.24/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml +++ b/tests/golden/kubernetes_1.24/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml @@ -14,17 +14,7 @@ metadata: namespace: syn-prometheus stringData: alertmanager.yaml: "\"global\":\n \"resolve_timeout\": \"5m\"\n\"inhibit_rules\"\ - :\n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_matchers\":\n\ - \ - \"severity = critical\"\n \"target_matchers\":\n - \"severity =~ warning|info\"\ - \n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_matchers\":\n\ - \ - \"severity = warning\"\n \"target_matchers\":\n - \"severity = info\"\n\ - - \"equal\":\n - \"namespace\"\n \"source_matchers\":\n - \"alertname = InfoInhibitor\"\ - \n \"target_matchers\":\n - \"severity = info\"\n\"receivers\":\n- \"name\"\ - : \"Default\"\n- \"name\": \"Watchdog\"\n- \"name\": \"Critical\"\n- \"name\"\ - : \"null\"\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"group_interval\"\ - : \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\n \"repeat_interval\"\ - : \"12h\"\n \"routes\":\n - \"matchers\":\n - \"alertname = Watchdog\"\n\ - \ \"receiver\": \"Watchdog\"\n - \"matchers\":\n - \"alertname = InfoInhibitor\"\ - \n \"receiver\": \"null\"\n - \"matchers\":\n - \"severity = critical\"\ - \n \"receiver\": \"Critical\"" + : []\n\"receivers\": []\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"\ + group_interval\": \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\ + \n \"repeat_interval\": \"12h\"\n \"routes\": []" type: Opaque diff --git a/tests/golden/openshift/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml b/tests/golden/openshift/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml index 7454e58..b03a3f6 100644 --- a/tests/golden/openshift/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml +++ b/tests/golden/openshift/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml @@ -14,14 +14,7 @@ metadata: namespace: syn-prometheus stringData: alertmanager.yaml: "\"global\":\n \"resolve_timeout\": \"5m\"\n\"inhibit_rules\"\ - :\n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_matchers\":\n\ - \ - \"severity = critical\"\n \"target_matchers\":\n - \"severity =~ warning|info\"\ - \n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_matchers\":\n\ - \ - \"severity = warning\"\n \"target_matchers\":\n - \"severity = info\"\n\ - \"receivers\":\n- \"name\": \"Default\"\n- \"name\": \"Watchdog\"\n- \"name\"\ - : \"Critical\"\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"group_interval\"\ - : \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\n \"repeat_interval\"\ - : \"12h\"\n \"routes\":\n - \"matchers\":\n - \"alertname = Watchdog\"\n\ - \ \"receiver\": \"Watchdog\"\n - \"matchers\":\n - \"severity = critical\"\ - \n \"receiver\": \"Critical\"" + : []\n\"receivers\": []\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"\ + group_interval\": \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\ + \n \"repeat_interval\": \"12h\"\n \"routes\": []" type: Opaque diff --git a/tests/golden/rewrite-registries/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml b/tests/golden/rewrite-registries/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml index 4d6ceac..a245460 100644 --- a/tests/golden/rewrite-registries/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml +++ b/tests/golden/rewrite-registries/prometheus/prometheus/30_default-instance_alertmanager_secret.yaml @@ -14,14 +14,7 @@ metadata: namespace: syn-prometheus stringData: alertmanager.yaml: "\"global\":\n \"resolve_timeout\": \"5m\"\n\"inhibit_rules\"\ - :\n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_match\":\n \ - \ \"severity\": \"critical\"\n \"target_match_re\":\n \"severity\": \"warning|info\"\ - \n- \"equal\":\n - \"namespace\"\n - \"alertname\"\n \"source_match\":\n \ - \ \"severity\": \"warning\"\n \"target_match_re\":\n \"severity\": \"info\"\ - \n\"receivers\":\n- \"name\": \"Default\"\n- \"name\": \"Watchdog\"\n- \"name\"\ - : \"Critical\"\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"group_interval\"\ - : \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\n \"repeat_interval\"\ - : \"12h\"\n \"routes\":\n - \"match\":\n \"alertname\": \"Watchdog\"\n\ - \ \"receiver\": \"Watchdog\"\n - \"match\":\n \"severity\": \"critical\"\ - \n \"receiver\": \"Critical\"" + : []\n\"receivers\": []\n\"route\":\n \"group_by\":\n - \"namespace\"\n \"\ + group_interval\": \"5m\"\n \"group_wait\": \"30s\"\n \"receiver\": \"Default\"\ + \n \"repeat_interval\": \"12h\"\n \"routes\": []" type: Opaque