mirror of
https://github.com/prometheus-operator/kube-prometheus.git
synced 2025-11-02 09:01:02 +01:00
Add External mixin library
Add library for mixins
This commit is contained in:
parent
f5f72e1b50
commit
0268128bd1
38
jsonnet/kube-prometheus/lib/mixin.libsonnet
Normal file
38
jsonnet/kube-prometheus/lib/mixin.libsonnet
Normal file
@ -0,0 +1,38 @@
|
||||
local defaults = {
|
||||
name: error 'provide name',
|
||||
namespace: 'monitoring',
|
||||
labels: {
|
||||
prometheus: 'k8s',
|
||||
},
|
||||
mixin: error 'provide a mixin',
|
||||
};
|
||||
|
||||
function(params) {
|
||||
config:: defaults + params,
|
||||
|
||||
local m = self,
|
||||
|
||||
local prometheusRules = if std.objectHasAll(m.config.mixin, 'prometheusRules') || std.objectHasAll(m.config.mixin, 'prometheusAlerts') then {
|
||||
apiVersion: 'monitoring.coreos.com/v1',
|
||||
kind: 'PrometheusRule',
|
||||
metadata: {
|
||||
labels: m.config.labels,
|
||||
name: m.config.name,
|
||||
namespace: m.config.namespace,
|
||||
},
|
||||
spec: {
|
||||
local r = if std.objectHasAll(m.config.mixin, 'prometheusRules') then m.config.mixin.prometheusRules.groups else [],
|
||||
local a = if std.objectHasAll(m.config.mixin, 'prometheusAlerts') then m.config.mixin.prometheusAlerts.groups else [],
|
||||
groups: a + r,
|
||||
},
|
||||
},
|
||||
|
||||
local grafanaDashboards = if std.objectHasAll(m.config.mixin, 'grafanaDashboards') then (
|
||||
if std.objectHas(m.config, 'dashboardFolder') then {
|
||||
[m.config.dashboardFolder]+: m.config.mixin.grafanaDashboards,
|
||||
} else (m.config.mixin.grafanaDashboards)
|
||||
),
|
||||
|
||||
prometheusRules: prometheusRules,
|
||||
grafanaDashboards: grafanaDashboards,
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user