Skip to content

Commit

Permalink
feat(argo-cd): Allow service monitor relabeling configs (argoproj#897)
Browse files Browse the repository at this point in the history
* Allow service monitor relabeling configs

Signed-off-by: Petr Drastil <[email protected]>

* Revert scrape interval to optional field

Signed-off-by: Petr Drastil <[email protected]>

* Revert path to original place

Signed-off-by: Petr Drastil <[email protected]>

* Fix trailing character on README

Signed-off-by: Marco Kilchhofer <[email protected]>

Co-authored-by: Marco Kilchhofer <[email protected]>
  • Loading branch information
pdrastil and mkilchhofer authored Aug 25, 2021
1 parent 91e6e07 commit 8e11387
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 30 deletions.
5 changes: 3 additions & 2 deletions charts/argo-cd/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: 2.1.0
description: A Helm chart for ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes.
name: argo-cd
version: 3.15.0
version: 3.16.0
home: https://github.com/argoproj/argo-helm
icon: https://argoproj.github.io/argo-cd/assets/logo.png
keywords:
Expand All @@ -21,4 +21,5 @@ dependencies:
condition: redis-ha.enabled
annotations:
artifacthub.io/changes: |
- "[Added]: Global configuration for pod annotations and labels"
- "[Added]: Service monitor relabelings and metricsRelabelings"
- "[Fixed]: Service monitor interval configuration for all components"
8 changes: 8 additions & 0 deletions charts/argo-cd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ NAME: my-release
| controller.metrics.service.servicePort | Metrics service port | `8082` |
| controller.metrics.serviceMonitor.enabled | Enable a prometheus ServiceMonitor. | `false` |
| controller.metrics.serviceMonitor.selector | Prometheus ServiceMonitor selector. | `{}` |
| controller.metrics.serviceMonitor.relabelings | Prometheus [RelabelConfigs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config) to apply to samples before scraping | `[]` |
| controller.metrics.serviceMonitor.metricRelabelings | Prometheus [MetricRelabelConfigs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs) to apply to samples before ingestion | `[]` |
| controller.name | Controller name string. | `"application-controller"` |
| controller.nodeSelector | [Node selector](https://kubernetes.io/docs/user-guide/node-selection/) | `{}` |
| controller.podAnnotations | Annotations for the controller pods | `{}` |
Expand Down Expand Up @@ -255,6 +257,8 @@ NAME: my-release
| repoServer.metrics.service.servicePort | Metrics service port | `8082` |
| repoServer.metrics.serviceMonitor.enabled | Enable a prometheus ServiceMonitor. | `false` |
| repoServer.metrics.serviceMonitor.selector | Prometheus ServiceMonitor selector. | `{}` |
| repoServer.metrics.serviceMonitor.relabelings | Prometheus [RelabelConfigs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config) to apply to samples before scraping | `[]` |
| repoServer.metrics.serviceMonitor.metricRelabelings | Prometheus [MetricRelabelConfigs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs) to apply to samples before ingestion | `[]` |
| repoServer.name | Repo server name | `"repo-server"` |
| repoServer.nodeSelector | [Node selector](https://kubernetes.io/docs/user-guide/node-selection/) | `{}` |
| repoServer.podAnnotations | Annotations for the repo server pods | `{}` |
Expand Down Expand Up @@ -335,6 +339,8 @@ NAME: my-release
| server.metrics.service.servicePort | Metrics service port | `8082` |
| server.metrics.serviceMonitor.enabled | Enable a prometheus ServiceMonitor. | `false` |
| server.metrics.serviceMonitor.selector | Prometheus ServiceMonitor selector. | `{}` |
| server.metrics.serviceMonitor.relabelings | Prometheus [RelabelConfigs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config) to apply to samples before scraping | `[]` |
| server.metrics.serviceMonitor.metricRelabelings | Prometheus [MetricRelabelConfigs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs) to apply to samples before ingestion | `[]` |
| server.name | Argo CD server name | `"server"` |
| server.nodeSelector | [Node selector](https://kubernetes.io/docs/user-guide/node-selection/) | `{}` |
| server.podAnnotations | Annotations for the server pods | `{}` |
Expand Down Expand Up @@ -387,6 +393,8 @@ NAME: my-release
| dex.metrics.service.labels | Metrics service labels | `{}` |
| dex.metrics.serviceMonitor.enabled | Enable a prometheus ServiceMonitor. | `false` |
| dex.metrics.serviceMonitor.selector | Prometheus ServiceMonitor selector. | `{}` |
| dex.metrics.serviceMonitor.relabelings | Prometheus [RelabelConfigs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config) to apply to samples before scraping | `[]` |
| dex.metrics.serviceMonitor.metricRelabelings | Prometheus [MetricRelabelConfigs](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs) to apply to samples before ingestion | `[]` |
| dex.name | Dex name | `"dex-server"` |
| dex.env | Environment variables for the Dex server. | `[]` |
| dex.envFrom | `envFrom` to pass to the Dex server. | `[]` (See [values.yaml](values.yaml)) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "argo-cd.controller.fullname" . }}
{{- if .Values.controller.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.controller.metrics.serviceMonitor.namespace }}
{{- with .Values.controller.metrics.serviceMonitor.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "argo-cd.labels" (dict "context" . "component" .Values.controller.name "name" .Values.controller.name) | nindent 4 }}
{{- if .Values.controller.metrics.serviceMonitor.selector }}
{{- toYaml .Values.controller.metrics.serviceMonitor.selector | nindent 4 }}
{{- with .Values.controller.metrics.serviceMonitor.selector }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.controller.metrics.serviceMonitor.additionalLabels }}
{{- toYaml .Values.controller.metrics.serviceMonitor.additionalLabels | nindent 4 }}
{{- with .Values.controller.metrics.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
Expand All @@ -21,11 +21,18 @@ spec:
interval: {{ . }}
{{- end }}
path: /metrics
{{- with .Values.controller.metrics.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.controller.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "argo-cd.selectorLabels" (dict "context" . "component" .Values.controller.name "name" "metrics") | nindent 6 }}
{{- end }}

21 changes: 14 additions & 7 deletions charts/argo-cd/templates/argocd-repo-server/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "argo-cd.repoServer.fullname" . }}
{{- if .Values.repoServer.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.repoServer.metrics.serviceMonitor.namespace }}
{{- with .Values.repoServer.metrics.serviceMonitor.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "argo-cd.labels" (dict "context" . "component" .Values.repoServer.name "name" .Values.repoServer.name) | nindent 4 }}
{{- if .Values.repoServer.metrics.serviceMonitor.selector }}
{{- toYaml .Values.repoServer.metrics.serviceMonitor.selector | nindent 4 }}
{{- with .Values.repoServer.metrics.serviceMonitor.selector }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.repoServer.metrics.serviceMonitor.additionalLabels }}
{{- toYaml .Values.repoServer.metrics.serviceMonitor.additionalLabels | nindent 4 }}
{{- with .Values.repoServer.metrics.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
Expand All @@ -21,11 +21,18 @@ spec:
interval: {{ . }}
{{- end }}
path: /metrics
{{- with .Values.repoServer.metrics.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.repoServer.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "argo-cd.selectorLabels" (dict "context" . "component" .Values.repoServer.name "name" (printf "%s-metrics" .Values.repoServer.name)) | nindent 6 }}
{{- end }}

19 changes: 13 additions & 6 deletions charts/argo-cd/templates/argocd-server/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,31 @@ metadata:
{{- end }}
labels:
{{- include "argo-cd.labels" (dict "context" . "component" .Values.server.name "name" .Values.server.name) | nindent 4 }}
{{- if .Values.server.metrics.serviceMonitor.selector }}
{{- toYaml .Values.server.metrics.serviceMonitor.selector | nindent 4 }}
{{- with .Values.server.metrics.serviceMonitor.selector }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.server.metrics.serviceMonitor.additionalLabels }}
{{- toYaml .Values.server.metrics.serviceMonitor.additionalLabels | nindent 4 }}
{{- with .Values.server.metrics.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: metrics
{{- with .Values.controller.metrics.serviceMonitor.interval }}
{{- with .Values.server.metrics.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
path: /metrics
{{- with .Values.server.metrics.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "argo-cd.selectorLabels" (dict "context" . "component" .Values.server.name "name" (printf "%s-metrics" .Values.server.name)) | nindent 6 }}
{{- end }}

24 changes: 16 additions & 8 deletions charts/argo-cd/templates/dex/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,36 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "argo-cd.dex.fullname" . }}
{{- if .Values.dex.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.dex.metrics.serviceMonitor.namespace }}
{{- with .Values.dex.metrics.serviceMonitor.namespace }}
namespace: {{ . }}
{{- end }}
labels:
{{- include "argo-cd.labels" (dict "context" . "component" .Values.dex.name "name" .Values.dex.name) | nindent 4 }}
{{- if .Values.dex.metrics.serviceMonitor.selector }}
{{- toYaml .Values.dex.metrics.serviceMonitor.selector | nindent 4 }}
{{- with .Values.dex.metrics.serviceMonitor.selector }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.dex.metrics.serviceMonitor.additionalLabels }}
{{- toYaml .Values.dex.metrics.serviceMonitor.additionalLabels | nindent 4 }}
{{- with .Values.dex.metrics.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: metrics
{{- with .Values.controller.metrics.serviceMonitor.interval }}
{{- with .Values.dex.metrics.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
path: /metrics
{{- with .Values.dex.metrics.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.dex.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . |nindent 8 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
{{- include "argo-cd.selectorLabels" (dict "context" . "component" .Values.dex.name "name" .Values.dex.name) | nindent 6 }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/argo-cd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ controller:
serviceMonitor:
enabled: false
interval: 30s
relabelings: []
metricRelabelings: []
# selector:
# prometheus: kube-prometheus
# namespace: monitoring
Expand Down Expand Up @@ -230,6 +232,8 @@ dex:
serviceMonitor:
enabled: false
interval: 30s
relabelings: []
metricRelabelings: []
# selector:
# prometheus: kube-prometheus
# namespace: monitoring
Expand Down Expand Up @@ -576,6 +580,8 @@ server:
serviceMonitor:
enabled: false
interval: 30s
relabelings: []
metricRelabelings: []
# selector:
# prometheus: kube-prometheus
# namespace: monitoring
Expand Down Expand Up @@ -961,6 +967,8 @@ repoServer:
serviceMonitor:
enabled: false
interval: 30s
relabelings: []
metricRelabelings: []
# selector:
# prometheus: kube-prometheus
# namespace: monitoring
Expand Down

0 comments on commit 8e11387

Please sign in to comment.