Skip to content

Commit

Permalink
Merge pull request #42 from techops-services/common-servicemonitor
Browse files Browse the repository at this point in the history
Add ServiceMonitor template to common Helm chart
  • Loading branch information
eskp authored Feb 6, 2025
2 parents c7c5c80 + f0542d1 commit 743d413
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
4 changes: 2 additions & 2 deletions charts/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.36
version: 0.0.37

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.36"
appVersion: "0.0.37"
icon: https://cncf-branding.netlify.app/img/projects/helm/horizontal/color/helm-horizontal-color.png
52 changes: 52 additions & 0 deletions charts/common/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- if and .Values.serviceMonitor.enabled .Values.service }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "common.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- else }}
namespace: {{ .Release.Namespace }}
{{- end }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: {{ .Values.serviceMonitor.port }}
{{- if .Values.serviceMonitor.path }}
path: {{ .Values.serviceMonitor.path }}
{{- end }}
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- if .Values.serviceMonitor.scheme }}
scheme: {{ .Values.serviceMonitor.scheme }}
{{- end }}
{{- with .Values.serviceMonitor.tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 8 }}
{{- end }}
selector:
matchLabels:
{{- include "common.selectorLabels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- with .Values.serviceMonitor.spec }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions charts/common/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,30 @@ env:
# type: parameterStore
# name: example-db
# parameter_name: DB_PASSWORD

serviceMonitor:
enabled: false
# The label used by the Prometheus Operator to discover ServiceMonitors
additionalLabels: {}
# release: prometheus-operator
# Namespace where ServiceMonitor resource will be created
namespace: ""
# Interval at which metrics should be scraped
interval: 30s
# Timeout for scraping
scrapeTimeout: 10s
# The path at which metrics are exposed
path: /metrics
# The port name or number to scrape metrics from
port: metrics
# Additional relabeling configurations
relabelings: []
# Additional metric relabeling configurations
metricRelabelings: []
# Scheme to use for scraping
scheme: http
# TLS configuration for scraping
tlsConfig: {}
# insecureSkipVerify: true
# Additional ServiceMonitor specifications
spec: {}

0 comments on commit 743d413

Please sign in to comment.