Skip to content

Commit

Permalink
Add ServiceMonitor support to Telegraf chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Idanbunimovich committed Feb 13, 2025
1 parent 3f94d31 commit ba41f35
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions charts/telegraf/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ spec:
{{- end }}
selector:
{{- include "telegraf.selectorLabels" . | nindent 4 }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- end -}}
18 changes: 18 additions & 0 deletions charts/telegraf/templates/servicemonitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "telegraf.fullname" . }}
labels:
app: {{ include "telegraf.name" . }}
{{- with .Values.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ include "telegraf.name" . }}
endpoints:
- port: prometheus-client
interval: {{ .Values.serviceMonitor.interval | default "10s" }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/telegraf/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,9 @@ pdb:
# - name: http
# containerPort: 9273
# protocol: TCP

serviceMonitor:
enabled: false # Set to true to enable ServiceMonitor
interval: 10s # Scrape interval; adjust as needed
labels: # Optional: add custom labels if desired
release: ""

0 comments on commit ba41f35

Please sign in to comment.