From ea6fe6436ff9e3ede6a3e780f101a6f14a169d92 Mon Sep 17 00:00:00 2001 From: Meza Date: Tue, 14 Mar 2023 03:26:47 -0400 Subject: [PATCH] Add podTargeLabels to Prometheus ServiceMonitor CRDs (#439) * Add podTargeLabels to Prometheus ServiceMonitor CRDs #437 Signed-off-by: John Meza * Add correct PR number to CHANGELOG Signed-off-by: John Meza * Fix typo in podTargetLabels Signed-off-by: John Meza --------- Signed-off-by: John Meza --- CHANGELOG.md | 1 + README.md | 11 +++++++++++ .../alertmanager/alertmanager-servicemonitor.yaml | 6 ++++++ templates/compactor/compactor-servicemonitor.yaml | 6 ++++++ templates/distributor/distributor-servicemonitor.yaml | 6 ++++++ templates/ingester/ingester-servicemonitor.yaml | 6 ++++++ .../overrides-exporter-servicemonitor.yaml | 6 ++++++ templates/purger/purger-servicemonitor.yaml | 6 ++++++ templates/querier/querier-servicemonitor.yaml | 6 ++++++ .../query-frontend/query-frontend-servicemonitor.yaml | 6 ++++++ .../query-scheduler-servicemonitor.yaml | 6 ++++++ templates/ruler/ruler-servicemonitor.yaml | 6 ++++++ .../store-gateway/store-gateway-servicemonitor.yaml | 6 ++++++ values.yaml | 11 +++++++++++ 14 files changed, 89 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe9997b..1fd69999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * [FEATURE] add autoscaler for the ruler #430 * [ENHANCEMENT] Add annotations and labels to memberlist service #433 +* [ENHANCEMENT] Add podTargetLabels to all Prometheus servicemonitor CRs #439 # 2.0.1 / 2023-01-06 diff --git a/README.md b/README.md index eb81b09b..1f13cdab 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ Kubernetes: `^1.19.0-0` | alertmanager.​serviceMonitor.​enabled | bool | `false` | | | alertmanager.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | alertmanager.​serviceMonitor.​metricRelabelings | list | `[]` | | +| alertmanager.​serviceMonitor.​podTargetLabels | list | `[]` | | | alertmanager.​serviceMonitor.​relabelings | list | `[]` | | | alertmanager.​sidecar.​containerSecurityContext.​enabled | bool | `true` | | | alertmanager.​sidecar.​containerSecurityContext.​readOnlyRootFilesystem | bool | `true` | | @@ -203,6 +204,7 @@ Kubernetes: `^1.19.0-0` | compactor.​serviceMonitor.​enabled | bool | `false` | | | compactor.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | compactor.​serviceMonitor.​metricRelabelings | list | `[]` | | +| compactor.​serviceMonitor.​podTargetLabels | list | `[]` | | | compactor.​serviceMonitor.​relabelings | list | `[]` | | | compactor.​startupProbe.​failureThreshold | int | `60` | | | compactor.​startupProbe.​httpGet.​path | string | `"/ready"` | | @@ -298,6 +300,7 @@ Kubernetes: `^1.19.0-0` | distributor.​serviceMonitor.​enabled | bool | `false` | | | distributor.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | distributor.​serviceMonitor.​metricRelabelings | list | `[]` | | +| distributor.​serviceMonitor.​podTargetLabels | list | `[]` | | | distributor.​serviceMonitor.​relabelings | list | `[]` | | | distributor.​startupProbe.​failureThreshold | int | `10` | | | distributor.​startupProbe.​httpGet.​path | string | `"/ready"` | | @@ -361,6 +364,7 @@ Kubernetes: `^1.19.0-0` | ingester.​serviceMonitor.​enabled | bool | `false` | | | ingester.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | ingester.​serviceMonitor.​metricRelabelings | list | `[]` | | +| ingester.​serviceMonitor.​podTargetLabels | list | `[]` | | | ingester.​serviceMonitor.​relabelings | list | `[]` | | | ingester.​startupProbe | object | `{}` | Startup/liveness probes for ingesters are not recommended. Ref: https://cortexmetrics.io/docs/guides/running-cortex-on-kubernetes/#take-extra-care-with-ingesters | | ingester.​statefulSet.​enabled | bool | `false` | If true, use a statefulset instead of a deployment for pod management. This is useful when using WAL | @@ -506,6 +510,7 @@ Kubernetes: `^1.19.0-0` | overrides_exporter.​serviceMonitor.​enabled | bool | `false` | | | overrides_exporter.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | overrides_exporter.​serviceMonitor.​metricRelabelings | list | `[]` | | +| overrides_exporter.​serviceMonitor.​podTargetLabels | list | `[]` | | | overrides_exporter.​serviceMonitor.​relabelings | list | `[]` | | | overrides_exporter.​startupProbe.​failureThreshold | int | `10` | | | overrides_exporter.​startupProbe.​httpGet.​path | string | `"/ready"` | | @@ -548,6 +553,7 @@ Kubernetes: `^1.19.0-0` | purger.​serviceMonitor.​enabled | bool | `false` | | | purger.​serviceMonitor.​extraEndpointSpec | object | `{}` | | | purger.​serviceMonitor.​metricRelabelings | list | `[]` | | +| purger.​serviceMonitor.​podTargetLabels | list | `[]` | | | purger.​serviceMonitor.​relabelings | list | `[]` | | | purger.​startupProbe.​failureThreshold | int | `60` | | | purger.​startupProbe.​httpGet.​path | string | `"/ready"` | | @@ -600,6 +606,7 @@ Kubernetes: `^1.19.0-0` | querier.​serviceMonitor.​enabled | bool | `false` | | | querier.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | querier.​serviceMonitor.​metricRelabelings | list | `[]` | | +| querier.​serviceMonitor.​podTargetLabels | list | `[]` | | | querier.​serviceMonitor.​relabelings | list | `[]` | | | querier.​startupProbe.​failureThreshold | int | `10` | | | querier.​startupProbe.​httpGet.​path | string | `"/ready"` | | @@ -646,6 +653,7 @@ Kubernetes: `^1.19.0-0` | query_frontend.​serviceMonitor.​enabled | bool | `false` | | | query_frontend.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | query_frontend.​serviceMonitor.​metricRelabelings | list | `[]` | | +| query_frontend.​serviceMonitor.​podTargetLabels | list | `[]` | | | query_frontend.​serviceMonitor.​relabelings | list | `[]` | | | query_frontend.​startupProbe.​failureThreshold | int | `10` | | | query_frontend.​startupProbe.​httpGet.​path | string | `"/ready"` | | @@ -691,6 +699,7 @@ Kubernetes: `^1.19.0-0` | query_scheduler.​serviceMonitor.​enabled | bool | `false` | | | query_scheduler.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | query_scheduler.​serviceMonitor.​metricRelabelings | list | `[]` | | +| query_scheduler.​serviceMonitor.​podTargetLabels | list | `[]` | | | query_scheduler.​serviceMonitor.​relabelings | list | `[]` | | | query_scheduler.​startupProbe.​failureThreshold | int | `10` | | | query_scheduler.​startupProbe.​httpGet.​path | string | `"/ready"` | | @@ -738,6 +747,7 @@ Kubernetes: `^1.19.0-0` | ruler.​serviceMonitor.​enabled | bool | `false` | | | ruler.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | ruler.​serviceMonitor.​metricRelabelings | list | `[]` | | +| ruler.​serviceMonitor.​podTargetLabels | list | `[]` | | | ruler.​serviceMonitor.​relabelings | list | `[]` | | | ruler.​sidecar.​containerSecurityContext.​enabled | bool | `true` | | | ruler.​sidecar.​containerSecurityContext.​readOnlyRootFilesystem | bool | `true` | | @@ -821,6 +831,7 @@ Kubernetes: `^1.19.0-0` | store_gateway.​serviceMonitor.​enabled | bool | `false` | | | store_gateway.​serviceMonitor.​extraEndpointSpec | object | `{}` | Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint | | store_gateway.​serviceMonitor.​metricRelabelings | list | `[]` | | +| store_gateway.​serviceMonitor.​podTargetLabels | list | `[]` | | | store_gateway.​serviceMonitor.​relabelings | list | `[]` | | | store_gateway.​startupProbe.​failureThreshold | int | `60` | | | store_gateway.​startupProbe.​httpGet.​path | string | `"/ready"` | | diff --git a/templates/alertmanager/alertmanager-servicemonitor.yaml b/templates/alertmanager/alertmanager-servicemonitor.yaml index 14d4a9f1..39f265ac 100644 --- a/templates/alertmanager/alertmanager-servicemonitor.yaml +++ b/templates/alertmanager/alertmanager-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.alertmanager.serviceMonitor.interval }} diff --git a/templates/compactor/compactor-servicemonitor.yaml b/templates/compactor/compactor-servicemonitor.yaml index a33e849f..b8c38655 100644 --- a/templates/compactor/compactor-servicemonitor.yaml +++ b/templates/compactor/compactor-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.compactor.serviceMonitor.interval }} diff --git a/templates/distributor/distributor-servicemonitor.yaml b/templates/distributor/distributor-servicemonitor.yaml index 25936b4c..a4f0f4c7 100644 --- a/templates/distributor/distributor-servicemonitor.yaml +++ b/templates/distributor/distributor-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.distributor.serviceMonitor.interval }} diff --git a/templates/ingester/ingester-servicemonitor.yaml b/templates/ingester/ingester-servicemonitor.yaml index 0c145188..6429ff08 100644 --- a/templates/ingester/ingester-servicemonitor.yaml +++ b/templates/ingester/ingester-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.ingester.serviceMonitor.interval }} diff --git a/templates/overrides-exporter/overrides-exporter-servicemonitor.yaml b/templates/overrides-exporter/overrides-exporter-servicemonitor.yaml index c6a9c2ee..c281c8ad 100644 --- a/templates/overrides-exporter/overrides-exporter-servicemonitor.yaml +++ b/templates/overrides-exporter/overrides-exporter-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.overrides_exporter.serviceMonitor.interval }} diff --git a/templates/purger/purger-servicemonitor.yaml b/templates/purger/purger-servicemonitor.yaml index f0917720..6665187e 100644 --- a/templates/purger/purger-servicemonitor.yaml +++ b/templates/purger/purger-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.purger.serviceMonitor.interval }} diff --git a/templates/querier/querier-servicemonitor.yaml b/templates/querier/querier-servicemonitor.yaml index 965c563c..2211a3f6 100644 --- a/templates/querier/querier-servicemonitor.yaml +++ b/templates/querier/querier-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.querier.serviceMonitor.interval }} diff --git a/templates/query-frontend/query-frontend-servicemonitor.yaml b/templates/query-frontend/query-frontend-servicemonitor.yaml index 9874d517..0add8f3a 100644 --- a/templates/query-frontend/query-frontend-servicemonitor.yaml +++ b/templates/query-frontend/query-frontend-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.query_frontend.serviceMonitor.interval }} diff --git a/templates/query-scheduler/query-scheduler-servicemonitor.yaml b/templates/query-scheduler/query-scheduler-servicemonitor.yaml index 45bc5033..81c6f9e0 100644 --- a/templates/query-scheduler/query-scheduler-servicemonitor.yaml +++ b/templates/query-scheduler/query-scheduler-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.query_scheduler.serviceMonitor.interval }} diff --git a/templates/ruler/ruler-servicemonitor.yaml b/templates/ruler/ruler-servicemonitor.yaml index de6744f4..fedaa65f 100644 --- a/templates/ruler/ruler-servicemonitor.yaml +++ b/templates/ruler/ruler-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.ruler.serviceMonitor.interval }} diff --git a/templates/store-gateway/store-gateway-servicemonitor.yaml b/templates/store-gateway/store-gateway-servicemonitor.yaml index e8dd5297..36ca0d6b 100644 --- a/templates/store-gateway/store-gateway-servicemonitor.yaml +++ b/templates/store-gateway/store-gateway-servicemonitor.yaml @@ -20,6 +20,12 @@ spec: namespaceSelector: matchNames: - {{ .Release.Namespace | quote }} + {{- if .Values.purger.serviceMonitor.podTargetLabels }} + podTargetLabels: + {{- range .Values.purger.serviceMonitor.podTargetLabels }} + - {{ . }} + {{- end }} + {{- end }} endpoints: - port: http-metrics {{- if .Values.store_gateway.serviceMonitor.interval }} diff --git a/values.yaml b/values.yaml index 13aab21a..eca4b012 100644 --- a/values.yaml +++ b/values.yaml @@ -167,6 +167,7 @@ alertmanager: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -330,6 +331,7 @@ distributor: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -440,6 +442,7 @@ ingester: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -592,6 +595,7 @@ ruler: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -728,6 +732,7 @@ querier: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -832,6 +837,7 @@ query_frontend: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -922,6 +928,7 @@ query_scheduler: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -1010,6 +1017,7 @@ overrides_exporter: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -1095,6 +1103,7 @@ purger: relabelings: [] metricRelabelings: [] extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -1306,6 +1315,7 @@ store_gateway: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {} @@ -1433,6 +1443,7 @@ compactor: metricRelabelings: [] # -- Additional endpoint configuration https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#endpoint extraEndpointSpec: {} + podTargetLabels: [] resources: {}