Commit 9cf9b349 authored by Marc Cirauqui's avatar Marc Cirauqui Committed by Kubernetes Prow Robot

Add processor config to telegraf (#18558)

parent d6264920
apiVersion: v1 apiVersion: v1
name: telegraf name: telegraf
version: 1.1.8 version: 1.1.9
appVersion: 1.12 appVersion: 1.12
deprecated: false deprecated: false
description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics. description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics.
......
...@@ -189,3 +189,95 @@ Create chart name and version as used by the chart label. ...@@ -189,3 +189,95 @@ Create chart name and version as used by the chart label.
{{ end }} {{ end }}
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- define "processors" -}}
{{- range $processorIdx, $configObject := . -}}
{{- range $processor, $config := . -}}
[[processors.{{- $processor }}]]
{{- 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 {}" }}
{{ $key }} = [
{{- $numOut := len $value }}
{{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $value }}
{{- $i := int64 $b }}
{{- $tp := typeOf $val }}
{{- if eq $i $numOut }}
{{- if eq $tp "string" }}
{{ $val | quote }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $val | int64 }}
{{- end }}
{{- else }}
{{- if eq $tp "string" }}
{{ $val | quote }},
{{- end}}
{{- if eq $tp "float64" }}
{{ $val | int64 }},
{{- end }}
{{- end }}
{{- end }}
]
{{- end }}
{{- if eq $tp "map[string]interface {}" }}
[[processors.{{ $processor }}.{{ $key }}]]
{{- range $k, $v := $value }}
{{- $tps := typeOf $v }}
{{- if eq $tps "string" }}
{{ $k }} = {{ $v | quote }}
{{- end }}
{{- if eq $tps "[]interface {}"}}
{{ $k }} = [
{{- $numOut := len $value }}
{{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $v }}
{{- $i := int64 $b }}
{{- if eq $i $numOut }}
{{ $val | quote }}
{{- else }}
{{ $val | quote }},
{{- end }}
{{- end }}
]
{{- end }}
{{- if eq $tps "map[string]interface {}"}}
[processors.{{ $processor }}.{{ $key }}.{{ $k }}]
{{- range $foo, $bar := $v }}
{{- $tp := typeOf $bar -}}
{{- if eq $tp "string" }}
{{ $foo }} = {{ $bar | quote }}
{{- end }}
{{- if eq $tp "int" }}
{{ $foo }} = {{ $bar }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $foo }} = {{ int64 $bar }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
{{- end }}
{{- end -}}
...@@ -11,5 +11,6 @@ data: ...@@ -11,5 +11,6 @@ data:
telegraf.conf: |+ telegraf.conf: |+
{{ template "global_tags" .Values.config.global_tags }} {{ template "global_tags" .Values.config.global_tags }}
{{ template "agent" .Values.config.agent }} {{ template "agent" .Values.config.agent }}
{{ template "processors" .Values.config.processors }}
{{ template "outputs" .Values.config.outputs }} {{ template "outputs" .Values.config.outputs }}
{{ template "inputs" .Values.config.inputs -}} {{ template "inputs" .Values.config.inputs -}}
...@@ -48,6 +48,15 @@ config: ...@@ -48,6 +48,15 @@ config:
logfile: "" logfile: ""
hostname: "$HOSTNAME" hostname: "$HOSTNAME"
omit_hostname: false omit_hostname: false
processors:
- enum:
mapping:
field: "status"
dest: "status_code"
value_mappings:
healthy: 1
problem: 2
critical: 3
outputs: outputs:
- influxdb: - influxdb:
urls: urls:
......
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