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
6 changes: 6 additions & 0 deletions .github/workflows/helm-charts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ jobs:
INFLUXDB_ENTERPRISE_LICENSE_KEY: "${{ secrets.INFLUXDB_ENTERPRISE_LICENSE_KEY }}"
if: steps.list-changed.outputs.changed == 'true'

- name: Create custom resources
run: |
kubectl create -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yaml
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
id: install
run: |
set -o pipefail;
ct install --namespace=default 2>&1 | tee $RUNNER_TEMP/$GITHUB_RUN_NUMBER.txt
# When https://github.com/helm/chart-testing/issues/212 is fixed, this can be used to set the license key instead of using env from secret
# run: ct install --namespace=default --helm-extra-args="--set license.key=${INFLUXDB_ENTERPRISE_LICENSE_KEY}"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/patterns.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Error loading config file
Release not loaded
2 changes: 1 addition & 1 deletion charts/telegraf/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: telegraf
version: 1.8.22
version: 1.8.23
appVersion: 1.24.2
deprecated: false
description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics.
Expand Down
8 changes: 8 additions & 0 deletions charts/telegraf/ci/prometheus-monitor-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
config:
outputs:
- prometheus_client:
listen: ":9273"
serviceMonitor:
create: true
labels:
team: losers
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
25 changes: 25 additions & 0 deletions charts/telegraf/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- 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.labels }}
{{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
{{- end }}
{{- 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 }}
11 changes: 11 additions & 0 deletions charts/telegraf/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ 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:
# Extra Labels for the ServiceMonitor
labels: {}
# 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