From 6bc0b6ec06f9c8463d1b1513dc17281d51a29240 Mon Sep 17 00:00:00 2001 From: Firas Mosbehi Date: Mon, 9 Feb 2026 12:38:10 +0100 Subject: [PATCH] [prometheus-cloudwatch-exporter] Add commonLabels support Signed-off-by: Firas Mosbehi --- .../prometheus-cloudwatch-exporter/Chart.yaml | 2 +- .../ci/common-labels-values.yaml | 17 +++++++++++++++++ .../templates/_helpers.tpl | 13 +++++++++++++ .../templates/clusterrole.yaml | 5 +---- .../templates/clusterrolebinding.yaml | 5 +---- .../templates/configmap.yaml | 5 +---- .../templates/deployment.yaml | 8 ++++---- .../templates/ingress.yaml | 5 +---- .../templates/pdb.yaml | 5 +---- .../templates/prometheusrule.yaml | 7 ++++--- .../templates/secrets.yaml | 5 +---- .../templates/service.yaml | 5 +---- .../templates/serviceaccount.yaml | 5 +---- .../templates/servicemonitor.yaml | 7 ++++--- .../prometheus-cloudwatch-exporter/values.yaml | 2 ++ 15 files changed, 53 insertions(+), 43 deletions(-) create mode 100644 charts/prometheus-cloudwatch-exporter/ci/common-labels-values.yaml diff --git a/charts/prometheus-cloudwatch-exporter/Chart.yaml b/charts/prometheus-cloudwatch-exporter/Chart.yaml index 93f232c499af..d519a56a9ed1 100644 --- a/charts/prometheus-cloudwatch-exporter/Chart.yaml +++ b/charts/prometheus-cloudwatch-exporter/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "0.16.0" description: A Helm chart for prometheus cloudwatch-exporter name: prometheus-cloudwatch-exporter -version: 0.28.1 +version: 0.28.2 home: https://github.com/prometheus/cloudwatch_exporter sources: - https://github.com/prometheus/cloudwatch_exporter diff --git a/charts/prometheus-cloudwatch-exporter/ci/common-labels-values.yaml b/charts/prometheus-cloudwatch-exporter/ci/common-labels-values.yaml new file mode 100644 index 000000000000..026da8b5f5f1 --- /dev/null +++ b/charts/prometheus-cloudwatch-exporter/ci/common-labels-values.yaml @@ -0,0 +1,17 @@ +commonLabels: + team: observability + owner: platform + +serviceMonitor: + enabled: true + +prometheusRule: + enabled: true + rules: + - alert: CloudwatchExporterSample + expr: up == 0 + for: 5m + labels: + severity: warning + annotations: + summary: sample diff --git a/charts/prometheus-cloudwatch-exporter/templates/_helpers.tpl b/charts/prometheus-cloudwatch-exporter/templates/_helpers.tpl index c46dba657044..912176120e35 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/_helpers.tpl +++ b/charts/prometheus-cloudwatch-exporter/templates/_helpers.tpl @@ -35,6 +35,19 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Common labels +*/}} +{{- define "prometheus-cloudwatch-exporter.labels" -}} +app: {{ template "prometheus-cloudwatch-exporter.name" . }} +chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} +release: {{ .Release.Name }} +heritage: {{ .Release.Service }} +{{- with .Values.commonLabels }} +{{ toYaml . }} +{{- end }} +{{- end -}} + {{/* Create serviceAccountName for deployment. */}} diff --git a/charts/prometheus-cloudwatch-exporter/templates/clusterrole.yaml b/charts/prometheus-cloudwatch-exporter/templates/clusterrole.yaml index 9afa3037a4e2..85b7b0d06def 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/clusterrole.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/clusterrole.yaml @@ -4,10 +4,7 @@ kind: ClusterRole metadata: name: {{ template "prometheus-cloudwatch-exporter.fullname" . }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} rules: - apiGroups: [""] resources: ["secrets","configmap"] diff --git a/charts/prometheus-cloudwatch-exporter/templates/clusterrolebinding.yaml b/charts/prometheus-cloudwatch-exporter/templates/clusterrolebinding.yaml index d9708e7ab6f3..ec71a3b6d388 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/clusterrolebinding.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/clusterrolebinding.yaml @@ -4,10 +4,7 @@ kind: ClusterRoleBinding metadata: name: {{ template "prometheus-cloudwatch-exporter.fullname" . }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} subjects: - kind: ServiceAccount name: {{ template "prometheus-cloudwatch-exporter.serviceAccountName" . }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/configmap.yaml b/charts/prometheus-cloudwatch-exporter/templates/configmap.yaml index fa2699df3de6..a52c20908383 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/configmap.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/configmap.yaml @@ -4,10 +4,7 @@ metadata: name: {{ template "prometheus-cloudwatch-exporter.fullname" . }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} data: config.yml: | {{ tpl .Values.config . | nindent 4 }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/deployment.yaml b/charts/prometheus-cloudwatch-exporter/templates/deployment.yaml index 35544066f49a..3ab1eba4e04a 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/deployment.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/deployment.yaml @@ -4,10 +4,7 @@ metadata: name: {{ template "prometheus-cloudwatch-exporter.fullname" . }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} {{- with .Values.deployment.labels }} {{- toYaml . | nindent 4 }} {{- end }} @@ -26,6 +23,9 @@ spec: labels: app: {{ template "prometheus-cloudwatch-exporter.name" . }} release: {{ .Release.Name }} + {{- with .Values.commonLabels }} +{{ toYaml . | indent 8 }} + {{- end }} {{- if .Values.pod.labels }} {{ toYaml .Values.pod.labels | indent 8 }} {{- end }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/ingress.yaml b/charts/prometheus-cloudwatch-exporter/templates/ingress.yaml index c58cf427e465..19ec9206a63c 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/ingress.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/ingress.yaml @@ -9,10 +9,7 @@ metadata: name: {{ $fullName }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} {{- if .Values.ingress.labels }} {{ toYaml .Values.ingress.labels | indent 4 }} {{- end }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/pdb.yaml b/charts/prometheus-cloudwatch-exporter/templates/pdb.yaml index 7a88ca5c6ed1..c31ae599be76 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/pdb.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/pdb.yaml @@ -5,10 +5,7 @@ metadata: name: {{ template "prometheus-cloudwatch-exporter.fullname" . }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} spec: {{- if .Values.podDisruptionBudget.minAvailable }} minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/prometheusrule.yaml b/charts/prometheus-cloudwatch-exporter/templates/prometheusrule.yaml index e0c0b8e44ce9..1037fb44c4c8 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/prometheusrule.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/prometheusrule.yaml @@ -3,10 +3,11 @@ apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: -{{- if .Values.prometheusRule.labels }} labels: -{{ toYaml .Values.prometheusRule.labels | indent 4}} -{{- end }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} + {{- with .Values.prometheusRule.labels }} +{{ toYaml . | indent 4}} + {{- end }} name: {{ $fullName }} {{- if .Values.prometheusRule.namespace }} namespace: {{ .Values.prometheusRule.namespace }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/secrets.yaml b/charts/prometheus-cloudwatch-exporter/templates/secrets.yaml index 7309b4d4fbe6..c68de53ce2b9 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/secrets.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/secrets.yaml @@ -5,10 +5,7 @@ metadata: name: {{ template "prometheus-cloudwatch-exporter.fullname" . }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - heritage: {{ .Release.Service }} - release: {{ .Release.Name }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} type: Opaque data: {{ if .Values.aws.aws_access_key_id }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/service.yaml b/charts/prometheus-cloudwatch-exporter/templates/service.yaml index 6fb1b125475d..86a92e77ace6 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/service.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/service.yaml @@ -6,10 +6,7 @@ metadata: annotations: {{ toYaml .Values.service.annotations | indent 4 }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} {{- if .Values.service.labels }} {{ toYaml .Values.service.labels | indent 4 }} {{- end }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/serviceaccount.yaml b/charts/prometheus-cloudwatch-exporter/templates/serviceaccount.yaml index 7eb7cf75ed7e..702540557a92 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/serviceaccount.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/serviceaccount.yaml @@ -6,10 +6,7 @@ metadata: name: {{ template "prometheus-cloudwatch-exporter.serviceAccountName" . }} namespace: {{ .Release.Namespace }} labels: - app: {{ template "prometheus-cloudwatch-exporter.name" . }} - chart: {{ template "prometheus-cloudwatch-exporter.chart" . }} - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} {{- if .Values.serviceAccount.annotations }} annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }} diff --git a/charts/prometheus-cloudwatch-exporter/templates/servicemonitor.yaml b/charts/prometheus-cloudwatch-exporter/templates/servicemonitor.yaml index ed9234f34fa0..b923b6b04d55 100644 --- a/charts/prometheus-cloudwatch-exporter/templates/servicemonitor.yaml +++ b/charts/prometheus-cloudwatch-exporter/templates/servicemonitor.yaml @@ -2,10 +2,11 @@ apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: -{{- if .Values.serviceMonitor.labels }} labels: -{{ toYaml .Values.serviceMonitor.labels | indent 4}} -{{- end }} + {{- include "prometheus-cloudwatch-exporter.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.labels }} +{{ toYaml . | indent 4}} + {{- end }} name: {{ template "prometheus-cloudwatch-exporter.fullname" . }} {{- if .Values.serviceMonitor.namespace }} namespace: {{ .Values.serviceMonitor.namespace }} diff --git a/charts/prometheus-cloudwatch-exporter/values.yaml b/charts/prometheus-cloudwatch-exporter/values.yaml index 2353ea73568a..4195d453904b 100644 --- a/charts/prometheus-cloudwatch-exporter/values.yaml +++ b/charts/prometheus-cloudwatch-exporter/values.yaml @@ -4,6 +4,8 @@ replicaCount: 1 +commonLabels: {} + image: repository: prom/cloudwatch-exporter # if not set appVersion field from Chart.yaml is used