From 81449209a5c9713d3a2bd3578ad0fc9c161f1c0b Mon Sep 17 00:00:00 2001 From: Jetchko Jekov Date: Tue, 7 Apr 2020 08:50:43 +0200 Subject: [PATCH] Fix serviceMonitorKubelet's metricRelabelings Insert the metricRelabelings at the proper level. Signed-off-by: Jetchko Jekov --- jsonnet/custom-prometheus.jsonnet | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/jsonnet/custom-prometheus.jsonnet b/jsonnet/custom-prometheus.jsonnet index 99b6caca00..9c733766ba 100644 --- a/jsonnet/custom-prometheus.jsonnet +++ b/jsonnet/custom-prometheus.jsonnet @@ -27,13 +27,21 @@ prometheus+:: { serviceMonitorKubelet+: { spec+: { - metricRelabelings+: [ - { - action: 'replace', - sourceLabels: ['node'], - targetLabel: 'instance', - }, - ], + endpoints: std.map(function(endpoint) + if endpoint.port == "https-metrics" then + endpoint { + metricRelabelings+: [ + { + action: 'replace', + sourceLabels: ['node'], + targetLabel: 'instance', + }, + ], + } + else + endpoint, + super.endpoints + ), }, }, },