Skip to content

Commit

Permalink
feat(helm): Add ServiceMonitor (#695)
Browse files Browse the repository at this point in the history
# Description

Adding support for `ServiceMonitor`.

## Checklist

- [x] I have read the [contributing
documentation](https://retina.sh/docs/contributing).
- [x] I have tested the changes locally.
- [x] I have followed the project's style guidelines.
- [x] I have updated the documentation, if necessary.

## Screenshots (if applicable) or Testing Completed

![image
(2)](https://github.com/user-attachments/assets/f377b3b0-c41f-48ce-8e1f-0eef562ecd73)

![image
(1)](https://github.com/user-attachments/assets/c11a6aa0-e897-43a3-b29c-2c2625554fb0)
  • Loading branch information
gciria authored Sep 11, 2024
1 parent e35d692 commit 9f6a62a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.metrics.podMonitor.enabled }}
{{- if and (not .Values.metrics.serviceMonitor.enabled) .Values.metrics.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- if and (not .Values.metrics.podMonitor.enabled) .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "retina.fullname" . }}
namespace: {{ ternary .Values.metrics.serviceMonitor.namespace .Values.namespace (not (empty .Values.metrics.serviceMonitor.namespace)) }}
labels:
k8s-app: {{ include "retina.name" . }}
{{- include "retina.labels" . | nindent 4 }}
app.kubernetes.io/component: metrics
{{- if .Values.metrics.serviceMonitor.additionalLabels }}
{{- toYaml .Values.metrics.serviceMonitor.additionalLabels | nindent 4 }}
{{- end }}
spec:
endpoints:
- targetPort: retina
path: /metrics
{{- if .Values.metrics.serviceMonitor.interval }}
interval: {{ .Values.metrics.serviceMonitor.interval }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.scheme }}
scheme: {{ .Values.metrics.serviceMonitor.scheme }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.tlsConfig }}
tlsConfig: {{- .Values.metrics.serviceMonitor.tlsConfig | nindent 8 }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.relabelings }}
relabelings:
{{- toYaml .Values.metrics.serviceMonitor.relabelings | nindent 8 }}
{{- end }}
{{- if .Values.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 8 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Values.namespace }}
selector:
matchLabels:
{{- include "retina.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: networking
{{- end }}
36 changes: 35 additions & 1 deletion deploy/legacy/manifests/controller/helm/retina/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,38 @@ metrics:
## @param metrics.podMonitor.relabelings [array] Prometheus relabeling rules
##
relabelings: []

serviceMonitor:
## @param metrics.serviceMonitor.enabled Create serviceMonitor Resource for scraping metrics using PrometheusOperator
##
enabled: false
## @param metrics.serviceMonitor.namespace Namespace in which the serviceMonitor should be created
##
namespace: ~
## @param metrics.serviceMonitor.interval Specify the interval at which metrics should be scraped
##
interval: 30s
## @param metrics.serviceMonitor.scrapeTimeout Specify the timeout after which the scrape is ended
##
scrapeTimeout: 30s
## @param metrics.serviceMonitor.additionalLabels [object] Additional labels that can be used so serviceMonitor will be discovered by Prometheus
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
##
additionalLabels: {}
## @param metrics.serviceMonitor.scheme Scheme to use for scraping
##
scheme: http
## @param metrics.serviceMonitor.tlsConfig [object] TLS configuration used for scrape endpoints used by Prometheus
## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/api.md#tlsconfig
## e.g:
## tlsConfig:
## ca:
## secret:
## name: existingSecretName
##
tlsConfig: {}
## @param metrics.serviceMonitor.relabelings [array] Prometheus relabeling rules to apply to samples before scraping
##
relabelings: []
## @param metrics.serviceMonitor.metricRelabelings [array] Prometheus relabeling rules to apply to samples before ingestion
##
metricRelabelings: []

0 comments on commit 9f6a62a

Please sign in to comment.