diff --git a/charts/dragonfly-operator/templates/servicemonitor.yaml b/charts/dragonfly-operator/templates/servicemonitor.yaml new file mode 100644 index 0000000..d14a399 --- /dev/null +++ b/charts/dragonfly-operator/templates/servicemonitor.yaml @@ -0,0 +1,40 @@ +{{- if .Values.serviceMonitor.enabled }} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + {{- include "dragonfly-operator.labels" . | nindent 4 }} + app.kubernetes.io/component: controller-manager-metrics + {{- if .Values.serviceMonitor.labels }} + {{- toYaml .Values.serviceMonitor.labels | nindent 4}} + {{- end }} + name: {{ include "dragonfly-operator.fullname" . }}-controller-manager-metrics +spec: + endpoints: + - targetPort: {{ .Values.service.port }} + {{- if .Values.serviceMonitor.interval }} + interval: {{ .Values.serviceMonitor.interval }} + {{- end }} + {{- if .Values.serviceMonitor.telemetryPath }} + path: {{ .Values.serviceMonitor.path }} + {{- end }} + {{- if .Values.serviceMonitor.timeout }} + scrapeTimeout: {{ .Values.serviceMonitor.timeout }} + {{- end }} + {{- if .Values.serviceMonitor.relabelings }} + relabelings: + {{ toYaml .Values.serviceMonitor.relabelings | indent 6 }} + {{- end }} + {{- if .Values.serviceMonitor.metricRelabelings }} + metricRelabelings: + {{ toYaml .Values.serviceMonitor.metricRelabelings | indent 6 }} + {{- end }} + jobLabel: {{ template "dragonfly-operator.fullname" . }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "dragonfly-operator.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/dragonfly-operator/values.yaml b/charts/dragonfly-operator/values.yaml index 186c6dc..0397be9 100644 --- a/charts/dragonfly-operator/values.yaml +++ b/charts/dragonfly-operator/values.yaml @@ -125,3 +125,26 @@ manager: # operator: In # values: # - linux + + +serviceMonitor: + # When set true then use a ServiceMonitor to configure scraping + enabled: false + # Set how frequently Prometheus should scrape + interval: 30s + # Set path to cloudwatch-exporter telemtery-path + path: /metrics + # Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator + labels: {} + # Set timeout for scrape + timeout: 10s + # Set relabelings for the ServiceMonitor, use to apply to samples before scraping + relabelings: [] + # Set metricRelabelings for the ServiceMonitor, use to apply to samples for ingestion + metricRelabelings: [] + # Example - note the Kubernetes convention of camelCase instead of Prometheus' snake_case + # metricRelabelings: + # - sourceLabels: [dbinstance_identifier] + # action: replace + # replacement: mydbname + # targetLabel: dbname \ No newline at end of file