Skip to content

Commit

Permalink
feat: add dedicated ServiceMonitor for operator
Browse files Browse the repository at this point in the history
  • Loading branch information
fstr committed Oct 2, 2024
1 parent b6bc47f commit 266ccce
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
6 changes: 6 additions & 0 deletions charts/pyrra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
32 changes: 32 additions & 0 deletions charts/pyrra/templates/servicemonitor-operator.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
14 changes: 14 additions & 0 deletions charts/pyrra/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 266ccce

Please sign in to comment.