Unverified Commit 17baa48c authored by alespour's avatar alespour Committed by GitHub

Fix probes and internal metrics configuration (#408)

* fix: enable probes when metrics or output health is enabled * fix: add option to control internal metrics
parent 99f6a75c
apiVersion: v2
name: telegraf
version: 1.8.10
appVersion: 1.21.1
version: 1.8.11
appVersion: 1.21.2
deprecated: false
description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics.
keywords:
......
# Default values only, no overrides
......@@ -532,3 +532,22 @@ Create the name of the service account to use
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Get health configuration
*/}}
{{- define "telegraf.health" -}}
{{- if .Values.metrics.health.enabled -}}
{{- .Values.metrics.health | toYaml -}}
{{- else -}}
{{- $health := dict -}}
{{- range $objectKey, $objectValue := .Values.config.outputs }}
{{- range $key, $value := . -}}
{{- if eq $key "health" -}}
{{- $health = $value -}}
{{- end -}}
{{- end -}}
{{- end }}
{{- $health | toYaml -}}
{{- end -}}
{{- end -}}
......@@ -13,14 +13,16 @@ data:
{{ template "outputs" .Values.config.outputs }}
{{- if .Values.metrics.health.enabled }}
[[outputs.health]]
service_address = "http://:8888"
service_address = "{{ .Values.metrics.health.service_address }}"
namepass = ["internal_write"]
[[outputs.health.compares]]
field = "buffer_size"
lt = {{ .Values.metrics.health.threshold }}
lt = {{ .Values.metrics.health.threshold | int64 }}.0
[[outputs.health.contains]]
field = "buffer_size"
{{- end }}
{{ template "inputs" .Values.config.inputs -}}
{{- if .Values.metrics.internal.enabled }}
[[inputs.internal]]
collect_memstats = {{ .Values.metrics.collect_memstats }}
collect_memstats = {{ or .Values.metrics.internal.collect_memstats (.Values.metrics.collect_memstats | default false) }}
{{- end }}
......@@ -77,20 +77,20 @@ spec:
{{ end }}
{{ end }}
{{ end }}
{{- range $objectKey, $objectValue := .Values.config.outputs }}
{{- range $key, $value := . -}}
{{- $tp := typeOf $value -}}
{{- if eq $key "health" }}
{{- $health := include "telegraf.health" . | fromYaml }}
{{- with $health }}
startupProbe:
httpGet:
path: /
port: {{ trimPrefix "http://:" .service_address | int64 }}
livenessProbe:
httpGet:
path: /
port: {{ trimPrefix "http://:" $value.service_address | int64 }}
port: {{ trimPrefix "http://:" .service_address | int64 }}
readinessProbe:
httpGet:
path: /
port: {{ trimPrefix "http://:" $value.service_address | int64 }}
{{- end }}
{{- end }}
port: {{ trimPrefix "http://:" .service_address | int64 }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
......
......@@ -12,9 +12,10 @@ metadata:
spec:
type: {{ .Values.service.type }}
ports:
{{- if .Values.metrics.health.enabled }}
- port: 8888
targetPort: 8888
{{- $health := include "telegraf.health" . | fromYaml }}
{{- with $health }}
- port: {{ trimPrefix "http://:" .service_address | int64 }}
targetPort: {{ trimPrefix "http://:" .service_address | int64 }}
name: "health"
{{- end }}
{{- range $objectKey, $objectValue := .Values.config.inputs }}
......
......@@ -170,8 +170,11 @@ config:
metrics:
health:
enabled: false
service_address: "http://:8888"
threshold: 5000.0
collect_memstats: false
internal:
enabled: true
collect_memstats: false
# Lifecycle hooks
# hooks:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment