From 9b39ab8a83fe55659760e4d9fa6c57231fb1d58e Mon Sep 17 00:00:00 2001 From: Tanmay Jain Date: Wed, 24 Jul 2024 16:06:09 +0530 Subject: [PATCH] Setting custom labels in prometheus. --- config/monitoring/alertmanager/service.yaml | 2 +- config/monitoring/alertmanager/statefulset.yaml | 2 +- config/monitoring/grafana/service.yaml | 2 +- config/monitoring/grafana/statefulset.yaml | 2 +- config/monitoring/kustomization.yaml | 2 +- config/monitoring/prometheus/clusterrolebinding.yaml | 2 +- config/monitoring/prometheus/config/prometheus.yml | 6 ++++++ config/monitoring/prometheus/service.yaml | 2 +- config/monitoring/prometheus/serviceaccount.yaml | 2 +- config/monitoring/prometheus/statefulset.yaml | 2 +- 10 files changed, 15 insertions(+), 9 deletions(-) diff --git a/config/monitoring/alertmanager/service.yaml b/config/monitoring/alertmanager/service.yaml index 32f98fdf2..4f420dea4 100644 --- a/config/monitoring/alertmanager/service.yaml +++ b/config/monitoring/alertmanager/service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: aerospike-monitoring-stack-alertmanager - namespace: default + namespace: monitoring labels: app: aerospike-monitoring-stack-alertmanager chart: aerospike-monitoring-stack diff --git a/config/monitoring/alertmanager/statefulset.yaml b/config/monitoring/alertmanager/statefulset.yaml index 26a30951d..030a84ae0 100644 --- a/config/monitoring/alertmanager/statefulset.yaml +++ b/config/monitoring/alertmanager/statefulset.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: aerospike-monitoring-stack-alertmanager - namespace: default + namespace: monitoring labels: app: aerospike-monitoring-stack-alertmanager chart: aerospike-monitoring-stack diff --git a/config/monitoring/grafana/service.yaml b/config/monitoring/grafana/service.yaml index babf9c925..daf1c118b 100644 --- a/config/monitoring/grafana/service.yaml +++ b/config/monitoring/grafana/service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: aerospike-monitoring-stack-grafana - namespace: default + namespace: monitoring labels: app: aerospike-monitoring-stack-grafana chart: aerospike-monitoring-stack diff --git a/config/monitoring/grafana/statefulset.yaml b/config/monitoring/grafana/statefulset.yaml index 6059c3101..741af25e7 100644 --- a/config/monitoring/grafana/statefulset.yaml +++ b/config/monitoring/grafana/statefulset.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: aerospike-monitoring-stack-grafana - namespace: default + namespace: monitoring labels: &Labels app: aerospike-monitoring-stack-grafana chart: aerospike-monitoring-stack diff --git a/config/monitoring/kustomization.yaml b/config/monitoring/kustomization.yaml index 00d91d7ee..481399bf0 100644 --- a/config/monitoring/kustomization.yaml +++ b/config/monitoring/kustomization.yaml @@ -1,6 +1,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -namespace: default +namespace: monitoring labels: - includeSelectors: true diff --git a/config/monitoring/prometheus/clusterrolebinding.yaml b/config/monitoring/prometheus/clusterrolebinding.yaml index bdbcaa373..802c1000b 100644 --- a/config/monitoring/prometheus/clusterrolebinding.yaml +++ b/config/monitoring/prometheus/clusterrolebinding.yaml @@ -13,4 +13,4 @@ roleRef: subjects: - kind: ServiceAccount name: aerospike-monitoring-stack - namespace: default \ No newline at end of file + namespace: monitoring \ No newline at end of file diff --git a/config/monitoring/prometheus/config/prometheus.yml b/config/monitoring/prometheus/config/prometheus.yml index a192f49da..f6699c4d5 100644 --- a/config/monitoring/prometheus/config/prometheus.yml +++ b/config/monitoring/prometheus/config/prometheus.yml @@ -62,6 +62,12 @@ scrape_configs: - default - aerospike relabel_configs: + - source_labels: + - __meta_kubernetes_namespace + target_label: namespace + - source_labels: + - __meta_kubernetes_pod_name + target_label: pod - action: keep regex: aerospike-cluster replacement: $1 diff --git a/config/monitoring/prometheus/service.yaml b/config/monitoring/prometheus/service.yaml index 228ba7127..16f18f445 100644 --- a/config/monitoring/prometheus/service.yaml +++ b/config/monitoring/prometheus/service.yaml @@ -2,7 +2,7 @@ kind: Service apiVersion: v1 metadata: name: aerospike-monitoring-stack-prometheus - namespace: default + namespace: monitoring labels: app: aerospike-monitoring-stack-prometheus chart: aerospike-monitoring-stack diff --git a/config/monitoring/prometheus/serviceaccount.yaml b/config/monitoring/prometheus/serviceaccount.yaml index ca44021d6..e67292c3d 100644 --- a/config/monitoring/prometheus/serviceaccount.yaml +++ b/config/monitoring/prometheus/serviceaccount.yaml @@ -6,4 +6,4 @@ metadata: chart: aerospike-monitoring-stack release: aerospike-monitoring-stack name: aerospike-monitoring-stack - namespace: default \ No newline at end of file + namespace: monitoring \ No newline at end of file diff --git a/config/monitoring/prometheus/statefulset.yaml b/config/monitoring/prometheus/statefulset.yaml index 18e486c24..9dbb256ea 100644 --- a/config/monitoring/prometheus/statefulset.yaml +++ b/config/monitoring/prometheus/statefulset.yaml @@ -2,7 +2,7 @@ apiVersion: apps/v1 kind: StatefulSet metadata: name: aerospike-monitoring-stack-prometheus - namespace: default + namespace: monitoring labels: &Labels app: aerospike-monitoring-stack-prometheus chart: aerospike-monitoring-stack