From 266ccce6480461032c88fbf452d5a8febe22fe30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Str=C3=BCbe?= Date: Wed, 2 Oct 2024 12:26:11 +0200 Subject: [PATCH] feat: add dedicated ServiceMonitor for operator --- charts/pyrra/README.md | 6 ++++ .../templates/servicemonitor-operator.yaml | 32 +++++++++++++++++++ ...onitor.yaml => servicemonitor-server.yaml} | 12 ------- charts/pyrra/values.yaml | 14 ++++++++ 4 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 charts/pyrra/templates/servicemonitor-operator.yaml rename charts/pyrra/templates/{servicemonitor.yaml => servicemonitor-server.yaml} (70%) diff --git a/charts/pyrra/README.md b/charts/pyrra/README.md index 4cc2a6eec..37273171e 100644 --- a/charts/pyrra/README.md +++ b/charts/pyrra/README.md @@ -68,6 +68,12 @@ The dashboards can be deployed using a ConfigMap and get's automatically [reload | serviceMonitor.labels | object | `{}` | Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator | | serviceMonitor.metricRelabelings | list | `[]` | Set metric relabelings for the ServiceMonitor | | serviceMonitor.relabelings | list | `[]` | Set relabelings for the ServiceMonitor | +| serviceMonitorOperator.enabled | bool | `true` | enables servicemonitor for operator monitoring | +| serviceMonitorOperator.interval | string | `""` | Set interval for scraping metrics | +| serviceMonitorOperator.jobLabel | string | `""` | provides the possibility to override the jobName if needed | +| serviceMonitorOperator.labels | object | `{}` | Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator | +| serviceMonitorOperator.metricRelabelings | list | `[]` | Set metric relabelings for the ServiceMonitor | +| serviceMonitorOperator.relabelings | list | `[]` | Set relabelings for the ServiceMonitor | | tolerations | object | `{}` | tolerations for scheduling server pod | | validatingWebhookConfiguration.enabled | bool | `false` | enables admission webhook for server to validate SLOs, this requires cert-manager to be installed | diff --git a/charts/pyrra/templates/servicemonitor-operator.yaml b/charts/pyrra/templates/servicemonitor-operator.yaml new file mode 100644 index 000000000..247bcc1dc --- /dev/null +++ b/charts/pyrra/templates/servicemonitor-operator.yaml @@ -0,0 +1,32 @@ +{{- if .Values.serviceMonitorOperator.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "pyrra.fullname" . }} + labels: + {{- include "pyrra.labels" . | nindent 4 }} + {{- if .Values.serviceMonitorOperator.labels }} + {{- toYaml .Values.serviceMonitorOperator.labels | nindent 4}} + {{- end }} +spec: + jobLabel: {{ .Values.serviceMonitorOperator.jobLabel | default (printf "%s-operator" (include "pyrra.fullname" .)) }} + selector: + matchLabels: + {{- include "pyrra.selectorLabels" . | nindent 6 }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + endpoints: + - port: op-metrics + {{- if .Values.serviceMonitorOperator.interval }} + interval: {{ .Values.serviceMonitorOperator.interval }} + {{- end }} + {{- if .Values.serviceMonitorOperator.metricRelabelings }} + metricRelabelings: + {{- toYaml .Values.serviceMonitorOperator.metricRelabelings | nindent 6 }} + {{- end }} + {{- if .Values.serviceMonitorOperator.relabelings }} + relabelings: + {{- toYaml .Values.serviceMonitorOperator.relabelings | nindent 6 }} + {{- end }} +{{- end }} diff --git a/charts/pyrra/templates/servicemonitor.yaml b/charts/pyrra/templates/servicemonitor-server.yaml similarity index 70% rename from charts/pyrra/templates/servicemonitor.yaml rename to charts/pyrra/templates/servicemonitor-server.yaml index 59d5612d4..dc39b47a6 100644 --- a/charts/pyrra/templates/servicemonitor.yaml +++ b/charts/pyrra/templates/servicemonitor-server.yaml @@ -29,16 +29,4 @@ spec: relabelings: {{- toYaml .Values.serviceMonitor.relabelings | nindent 6 }} {{- end }} - - port: op-metrics - {{- if .Values.serviceMonitor.interval }} - interval: {{ .Values.serviceMonitor.interval }} - {{- end }} - {{- if .Values.serviceMonitor.metricRelabelings }} - metricRelabelings: - {{- toYaml .Values.serviceMonitor.metricRelabelings | nindent 6 }} - {{- end }} - {{- if .Values.serviceMonitor.relabelings }} - relabelings: - {{- toYaml .Values.serviceMonitor.relabelings | nindent 6 }} - {{- end }} {{- end }} diff --git a/charts/pyrra/values.yaml b/charts/pyrra/values.yaml index 5c8792221..41c695c7a 100644 --- a/charts/pyrra/values.yaml +++ b/charts/pyrra/values.yaml @@ -109,6 +109,20 @@ serviceMonitor: # -- Set relabelings for the ServiceMonitor relabelings: [] +serviceMonitorOperator: + # -- enables servicemonitor for operator monitoring + enabled: true + # -- Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator + labels: {} + # -- provides the possibility to override the jobName if needed + jobLabel: "" + # -- Set interval for scraping metrics + interval: "" + # -- Set metric relabelings for the ServiceMonitor + metricRelabelings: [] + # -- Set relabelings for the ServiceMonitor + relabelings: [] + prometheusRule: # -- enables creation of PrometheusRules to monitor Pyrra enabled: false