From 1c63b6d0213ad4ae47cd03384d51424fd1f5f3c9 Mon Sep 17 00:00:00 2001
From: mansikulkarni96 <mankulka@redhat.com>
Date: Wed, 31 Mar 2021 13:21:01 -0400
Subject: [PATCH] Add relabel_config to replace endpoint address

This commit adds a relabeling config to the scrape config of
windows-exporter using the 'replace' action field to replace
the node endpoint address with node name. The windows_exporter
returns endpoint target as node IP but we need it to be node name
to use the prometheus adapter queries and collect resource metrics
information.
---
 jsonnet/kube-prometheus/addons/windows.libsonnet | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/jsonnet/kube-prometheus/addons/windows.libsonnet b/jsonnet/kube-prometheus/addons/windows.libsonnet
index 04d2f6f4..d8112351 100644
--- a/jsonnet/kube-prometheus/addons/windows.libsonnet
+++ b/jsonnet/kube-prometheus/addons/windows.libsonnet
@@ -10,6 +10,17 @@ local windowsrules = import 'kubernetes-mixin/rules/windows.libsonnet';
           targets: [error 'must provide targets array'],
         },
       ],
+      relabel_configs: [
+        {
+          action: 'replace',
+          regex: '(.*)',
+          replacement: '$1',
+          sourceLabels: [
+            '__meta_kubernetes_endpoint_address_target_name',
+          ],
+          targetLabel: 'instance',
+        },
+      ],
     },
 
     grafana+:: {
-- 
GitLab