From 953a31ff3b873af0a468a3cb0c37ee8f7c8d3fe5 Mon Sep 17 00:00:00 2001 From: Jeff French Date: Wed, 10 Jan 2024 06:46:13 -0600 Subject: [PATCH] Add monitor for gitops-dashboard --- .../gitops-dashboard-servicemonitor.yaml | 43 +++++++++++++++++++ charts/moonswitch-agent/values.yaml | 14 +++++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 charts/moonswitch-agent/templates/gitops-dashboard-servicemonitor.yaml diff --git a/charts/moonswitch-agent/templates/gitops-dashboard-servicemonitor.yaml b/charts/moonswitch-agent/templates/gitops-dashboard-servicemonitor.yaml new file mode 100644 index 0000000..e018020 --- /dev/null +++ b/charts/moonswitch-agent/templates/gitops-dashboard-servicemonitor.yaml @@ -0,0 +1,43 @@ +{{ $weave_gitops := index .Values "weave-gitops" }} +{{- if and $weave_gitops.enabled $weave_gitops.metrics.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "moonswitch-agent.fullname" . }}-weave-gitops + labels: + {{- include "moonswitch-agent.labels" . | nindent 4 }} + {{- with $weave_gitops.metrics.serviceMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + jobLabel: {{ template "moonswitch-agent.fullname" . }}-weave-gitops + endpoints: + - port: http-metrics + {{- if $weave_gitops.metrics.serviceMonitor.path }} + path: {{ $weave_gitops.metrics.serviceMonitor.path }} + {{- end }} + {{- if $weave_gitops.metrics.serviceMonitor.interval }} + interval: {{ $weave_gitops.metrics.serviceMonitor.interval }} + {{- end }} + {{- if $weave_gitops.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ $weave_gitops.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} + {{- if $weave_gitops.metrics.serviceMonitor.metricRelabelings }} + metricRelabelings: + {{ toYaml $weave_gitops.metrics.serviceMonitor.metricRelabelings | indent 4 }} + {{- end }} + {{- if $weave_gitops.metrics.serviceMonitor.relabelings }} + relabelings: + {{ toYaml $weave_gitops.metrics.serviceMonitor.relabelings | indent 4 }} + {{- end }} + {{- if $weave_gitops.metrics.serviceMonitor.honorLabels }} + honorLabels: true + {{- end }} + selector: + matchLabels: + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/name: weave-gitops + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} +{{- end }} diff --git a/charts/moonswitch-agent/values.yaml b/charts/moonswitch-agent/values.yaml index 3e8ce4b..1a68b62 100644 --- a/charts/moonswitch-agent/values.yaml +++ b/charts/moonswitch-agent/values.yaml @@ -202,7 +202,19 @@ weave-gitops: metrics: enabled: true annotations: {} - # TODO: Write our own ServiceMonitor for this :2112/metrics + serviceMonitor: + enabled: true + # -- Interval at which endpoints should be scraped. + interval: 30s + # -- Add custom labels to the ServiceMonitor resource + additionalLabels: + monitored-by: moonswitch-agent + # -- Chooses the metric’s labels on collisions with target labels. + honorLabels: false + # -- Path to scrape metrics + path: /metrics + # -- Timeout for scrape metrics request + scrapeTimeout: 10s resources: requests: cpu: 10m