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

[telegraf] fix: add starlark_processor template #546

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.26
version: 1.8.27
appVersion: 1.25.2
deprecated: false
description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics.
Expand Down
26 changes: 25 additions & 1 deletion charts/telegraf/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- define "processors.v1" -}}
{{- range $processorIdx, $configObject := . -}}
{{- range $processor, $config := . -}}

{{- if eq $processor "starlark" }}
{{- include "telegraf.starlark_processor" . | nindent 4 }}
{{- else }}
[[processors.{{- $processor }}]]
{{- if $config -}}
{{- $tp := typeOf $config -}}
Expand Down Expand Up @@ -407,6 +409,7 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- end }}
{{ end }}
{{- end }}
{{- end }}
{{- end -}}

Expand Down Expand Up @@ -724,3 +727,24 @@ Get health configuration
{{- $health | toYaml -}}
{{- end -}}
{{- end -}}

{{/*
Helper function to create a starlark processor configuration block
*/}}
{{- define "telegraf.starlark_processor" -}}
[[processors.starlark]]
## The Starlark source can be set as a string in this configuration file, or
## by referencing a file containing the script. Only one source or script
## should be set at once.

## Source of the Starlark script.
source = '''
def apply(metric):
if metric.name == "prometheus_remote_write":
for k, v in metric.fields.items():
metric.name = k
metric.fields["value"] = v
metric.fields.pop(k)
return metric
'''
{{- end }}