From 1fb864ec21b86cb591e27309f26da0ae4739fc25 Mon Sep 17 00:00:00 2001 From: Arunprasad Rajkumar <arajkuma@redhat.com> Date: Thu, 9 Dec 2021 17:10:05 +0530 Subject: [PATCH] Remove `thanosSelector` and expose `mixin._config.thanos` config variable for thanos sidecar This commit removes existing `thanosSelector` and exposes a single config variable `mixin._config.thanos` to customize thanos sidecar mixins. It follows same structure as https://github.com/thanos-io/thanos/blob/d2d74dac9878f633f1fb0e253bcc0b1cdea376d3/mixin/config.libsonnet Signed-off-by: Arunprasad Rajkumar <arajkuma@redhat.com> --- .../components/prometheus.libsonnet | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/jsonnet/kube-prometheus/components/prometheus.libsonnet b/jsonnet/kube-prometheus/components/prometheus.libsonnet index dcd51ea6..0151ed99 100644 --- a/jsonnet/kube-prometheus/components/prometheus.libsonnet +++ b/jsonnet/kube-prometheus/components/prometheus.libsonnet @@ -34,7 +34,15 @@ local defaults = { _config: { prometheusSelector: 'job="prometheus-' + defaults.name + '",namespace="' + defaults.namespace + '"', prometheusName: '{{$labels.namespace}}/{{$labels.pod}}', - thanosSelector: 'job="thanos-sidecar"', + thanos: { + targetGroups: { + namespace: defaults.namespace, + }, + sidecar: { + selector: 'job="thanos-sidecar"', + thanosPrometheusCommonDimensions: 'namespace, pod', + }, + }, runbookURLPattern: 'https://runbooks.prometheus-operator.dev/runbooks/prometheus/%s', }, }, @@ -65,12 +73,8 @@ function(params) { (import 'github.com/thanos-io/thanos/mixin/alerts/sidecar.libsonnet') + (import 'github.com/kubernetes-monitoring/kubernetes-mixin/lib/add-runbook-links.libsonnet') + { _config+:: p._config.mixin._config, - targetGroups: {}, - sidecar: { - selector: p._config.mixin._config.thanosSelector, - thanosPrometheusCommonDimensions: 'namespace, pod', - dimensions: std.join(', ', ['job', 'instance']), - }, + targetGroups+: p._config.mixin._config.thanos.targetGroups, + sidecar+: p._config.mixin._config.thanos.sidecar, }, prometheusRule: { -- GitLab