diff --git a/charts/telegraf-ds/Chart.yaml b/charts/telegraf-ds/Chart.yaml index ad9a721b..d67f1a12 100644 --- a/charts/telegraf-ds/Chart.yaml +++ b/charts/telegraf-ds/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: telegraf-ds -version: 1.1.14 +version: 1.1.15 appVersion: 1.27.4 deprecated: false description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics. diff --git a/charts/telegraf-ds/templates/_helpers.tpl b/charts/telegraf-ds/templates/_helpers.tpl index 331bdc53..541a366b 100644 --- a/charts/telegraf-ds/templates/_helpers.tpl +++ b/charts/telegraf-ds/templates/_helpers.tpl @@ -394,6 +394,116 @@ app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{- end -}} +{{- define "inputs" -}} +{{- range $inputIdx, $configObject := . -}} + {{- range $input, $config := . -}} + + [[inputs.{{- $input }}]] + {{- if $config -}} + {{- $tp := typeOf $config -}} + {{- if eq $tp "map[string]interface {}" -}} + {{- range $key, $value := $config -}} + {{- $tp := typeOf $value -}} + {{- if eq $tp "string" }} + {{ $key }} = {{ $value | quote }} + {{- end }} + {{- if eq $tp "float64" }} + {{ $key }} = {{ $value | int64 }} + {{- end }} + {{- if eq $tp "int" }} + {{ $key }} = {{ $value | int64 }} + {{- end }} + {{- if eq $tp "bool" }} + {{ $key }} = {{ $value }} + {{- end }} + {{- if eq $tp "[]interface {}" }} + {{- if eq (index $value 0 | typeOf) "map[string]interface {}" -}} + {{- range $b, $val := $value }} + [[inputs.{{- $input }}.{{- $key }}]] + {{- range $k, $v := $val }} + {{- $tps := typeOf $v }} + {{- if eq $tps "string" }} + {{ $k }} = {{ $v | quote }} + {{- end }} + {{- if eq $tps "float64" }} + {{ $k }} = {{ $v | int64 }} + {{- end }} + {{- if eq $tps "bool" }} + {{ $k }} = {{ $v }} + {{- end }} + {{- end }} + {{- end }} + {{- else }} + {{ $key }} = [ + {{- $numOut := len $value }} + {{- $numOut := sub $numOut 1 }} + {{- range $b, $val := $value }} + {{- $i := int64 $b }} + {{- $tp := typeOf $val }} + {{- if eq $tp "string" }} + {{ $val | quote }} + {{- end }} + {{- if eq $tp "float64" }} + {{- if eq $key "percentiles" }} + {{- $xval := float64 (int64 $val) }} + {{- if eq $val $xval }} + {{ $val | int64 }}.0 + {{- else }} + {{ $val | float64 }} + {{- end }} + {{- else }} + {{ $val | int64 }} + {{- end }} + {{- end }} + {{- if ne $i $numOut -}} + , + {{- end -}} + {{- end }} + ] + {{- end }} + {{- end }} + {{- end }} + {{- range $key, $value := $config -}} + {{- $tp := typeOf $value -}} + {{- if eq $tp "map[string]interface {}" }} + [inputs.{{ $input }}.{{ $key }}] + {{- range $k, $v := $value }} + {{- $tps := typeOf $v }} + {{- if eq $tps "string" }} + {{ $k }} = {{ $v | quote }} + {{- end }} + {{- if eq $tps "[]interface {}"}} + {{ $k }} = [ + {{- $numOut := len $v }} + {{- $numOut := sub $numOut 1 }} + {{- range $b, $val := $v }} + {{- $i := int64 $b }} + {{- if eq $i $numOut }} + {{ $val | quote }} + {{- else }} + {{ $val | quote }}, + {{- end }} + {{- end }} + ] + {{- end }} + {{- end }} + {{- range $k, $v := $value }} + {{- $tps := typeOf $v }} + {{- if eq $tps "map[string]interface {}"}} + [inputs.{{ $input }}.{{ $key }}.{{ $k }}] + {{- range $foo, $bar := $v }} + {{ $foo }} = {{ $bar | quote }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{ end }} +{{- end }} +{{- end -}} + {{/* Create the name of the service account to use */}} diff --git a/charts/telegraf-ds/templates/configmap.yaml b/charts/telegraf-ds/templates/configmap.yaml index a98e15bd..9427e82e 100644 --- a/charts/telegraf-ds/templates/configmap.yaml +++ b/charts/telegraf-ds/templates/configmap.yaml @@ -16,31 +16,10 @@ data: {{ template "aggregators" .Values.config.aggregators }} {{ template "outputs" .Values.config.outputs }} {{ template "monitor_self" .Values.config.monitor_self }} - - [[inputs.diskio]] - [[inputs.kernel]] - [[inputs.mem]] - [[inputs.net]] - [[inputs.processes]] - [[inputs.swap]] - [[inputs.system]] - - [[inputs.cpu]] - percpu = true - totalcpu = true - collect_cpu_time = false - report_active = false - - [[inputs.disk]] - ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"] + {{ template "inputs" .Values.config.inputs }} {{- if .Values.config.docker_endpoint }} [[inputs.docker]] endpoint = {{ .Values.config.docker_endpoint | quote }} {{- end }} - - [[inputs.kubernetes]] - url = "https://$HOSTIP:10250" - bearer_token = "/var/run/secrets/kubernetes.io/serviceaccount/token" - insecure_skip_verify = true {{- end }} diff --git a/charts/telegraf-ds/values.yaml b/charts/telegraf-ds/values.yaml index b4b4e9f4..714b76f5 100644 --- a/charts/telegraf-ds/values.yaml +++ b/charts/telegraf-ds/values.yaml @@ -133,6 +133,32 @@ config: logfile: "" hostname: "$HOSTNAME" omit_hostname: false + inputs: + - diskio: {} + - kernel: {} + - mem: {} + - net: {} + - processes: {} + - swap: {} + - system: {} + - cpu: + percpu: true + totalcpu: true + collect_cpu_time: false + report_active: false + - disk: + ignore_fs: + - tmpfs + - devtmpfs + - devfs + - iso9660 + - overlay + - aufs + - squashfs + - kubernetes: + url: "https://$HOSTIP:10250" + bearer_token: "/var/run/secrets/kubernetes.io/serviceaccount/token" + insecure_skip_verify: true outputs: - influxdb: urls: