diff --git a/.github/workflows/helm-charts-test.yaml b/.github/workflows/helm-charts-test.yaml index e4938a96..94166d51 100644 --- a/.github/workflows/helm-charts-test.yaml +++ b/.github/workflows/helm-charts-test.yaml @@ -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}" diff --git a/.github/workflows/patterns.txt b/.github/workflows/patterns.txt index 13d5f6fb..f35a351e 100644 --- a/.github/workflows/patterns.txt +++ b/.github/workflows/patterns.txt @@ -1 +1,2 @@ Error loading config file +Release not loaded diff --git a/charts/telegraf/Chart.yaml b/charts/telegraf/Chart.yaml old mode 100755 new mode 100644 index 414744a6..e71b4a4c --- a/charts/telegraf/Chart.yaml +++ b/charts/telegraf/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: telegraf -version: 1.8.23 +version: 1.8.24 appVersion: 1.24.3 deprecated: false description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics. diff --git a/charts/telegraf/ci/prometheus-monitor-values.yaml b/charts/telegraf/ci/prometheus-monitor-values.yaml new file mode 100644 index 00000000..861b88ca --- /dev/null +++ b/charts/telegraf/ci/prometheus-monitor-values.yaml @@ -0,0 +1,8 @@ +config: + outputs: + - prometheus_client: + listen: ":9273" +serviceMonitor: + create: true + labels: + team: losers diff --git a/charts/telegraf/templates/_helpers.tpl b/charts/telegraf/templates/_helpers.tpl index d82af165..462f81e6 100644 --- a/charts/telegraf/templates/_helpers.tpl +++ b/charts/telegraf/templates/_helpers.tpl @@ -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 */}} diff --git a/charts/telegraf/templates/servicemonitor.yaml b/charts/telegraf/templates/servicemonitor.yaml new file mode 100644 index 00000000..361f2ff7 --- /dev/null +++ b/charts/telegraf/templates/servicemonitor.yaml @@ -0,0 +1,33 @@ +{{- if .Values.serviceMonitor.create }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "telegraf.serviceMonitorName" . }} + namespace: {{ .Values.serviceMonitor.namespaceOverride | default .Release.Namespace }} + labels: + {{- include "telegraf.labels" . | nindent 4 }} + {{- 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: + {{- range $objectKey, $objectValue := .Values.config.outputs }} + {{- range $key, $value := . -}} + {{- $tp := typeOf $value -}} + {{- if eq $key "prometheus_client" }} + - port: {{ trimPrefix ":" $value.listen }} + path: {{ $value.path | default "/metrics" }} + {{- end }} + {{- end -}} + {{- end }} +{{- end }} diff --git a/charts/telegraf/values.yaml b/charts/telegraf/values.yaml index eeec0087..a484dbee 100644 --- a/charts/telegraf/values.yaml +++ b/charts/telegraf/values.yaml @@ -109,6 +109,24 @@ serviceAccount: name: # Annotations for the ServiceAccount annotations: {} + +# To make use of the serviceMonitorm, please add a prometheus_client entry to config.outputs: + # - prometheus_client: + # listen: ":9273" + # path: /metrics +serviceMonitor: + # 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: {} + # To install the serviceMonitor in a different namespace than the release set its name here + # For example if your prometheus is