Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #417 Add serviceMonitor template for the telegraf chart #510

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
11 changes: 11 additions & 0 deletions charts/telegraf/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,17 @@ Create the name of the service account to use
{{- end -}}
{{- end -}}

{{/*
Create the name of the service monitor to use
*/}}
{{- define "telegraf.serviceMonitorName" -}}
{{- if .Values.serviceMonitor.create -}}
{{ default (include "telegraf.fullname" .) .Values.serviceMonitor.name }}
{{- else -}}
{{ default "default" .Values.serviceMonitor.name }}
{{- end -}}
{{- end -}}

{{/*
Get health configuration
*/}}
Expand Down
22 changes: 22 additions & 0 deletions charts/telegraf/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.serviceMonitor.create }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Efrat19 marked this conversation as resolved.
Show resolved Hide resolved
name: {{ template "telegraf.serviceMonitorName" . }}
labels:
{{- include "telegraf.labels" . | nindent 4 }}
alespour marked this conversation as resolved.
Show resolved Hide resolved
{{- if .Values.serviceMonitor.annotations }}
annotations:
{{- toYaml .Values.serviceMonitor.annotations | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "telegraf.labels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
endpoints:
- port: prometheus-client
Efrat19 marked this conversation as resolved.
Show resolved Hide resolved
path: /metrics
{{- end }}
9 changes: 9 additions & 0 deletions charts/telegraf/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ serviceAccount:
name:
# Annotations for the ServiceAccount
annotations: {}

serviceMonitor:
Efrat19 marked this conversation as resolved.
Show resolved Hide resolved
# Specifies whether a ServiceMonitor should be created
create: false
# The name of the ServiceMonitor to use.
# If not set and create is true, a name is generated using the fullname template
name:
# Annotations for the ServiceMonitor
annotations: {}
## Exposed telegraf configuration
## For full list of possible values see `/docs/all-config-values.yaml` and `/docs/all-config-values.toml`
## ref: https://docs.influxdata.com/telegraf/v1.1/administration/configuration/
Expand Down