Relabel the instance label for prometheus and loki metrics
The instance label for Prometheus had the value localhost:9090, which
was misleading.
Now the label is relabeled to prometheus-<namespace> or loki-<namespace>.
This is still not ideal for cases, where multiple replicas are deployed,
but until then, it is already a slight improvement.
Change-Id: I1efdc49071b1d3bf99d21315ca03821e9d58c906
diff --git a/charts/prometheus/prometheus.yaml b/charts/prometheus/prometheus.yaml
index 66ae8d8..decdc6c 100644
--- a/charts/prometheus/prometheus.yaml
+++ b/charts/prometheus/prometheus.yaml
@@ -1149,10 +1149,20 @@
static_configs:
- targets:
- localhost:9090
+ relabel_configs:
+ - source_labels: ["__address__"]
+ regex: ".*"
+ target_label: instance
+ replacement: #@ "prometheus-{}".format(data.values.namespace)
- job_name: loki
static_configs:
- targets:
- #@ "loki-{}.{}.svc.cluster.local:3100".format(data.values.namespace, data.values.namespace)
+ relabel_configs:
+ - source_labels: ["__address__"]
+ regex: ".*"
+ target_label: instance
+ replacement: #@ "loki-{}".format(data.values.namespace)
# A scrape configuration for running Prometheus on a Kubernetes cluster.
# This uses separate scrape configs for cluster components (i.e. API server, node)