influxdata / helm-charts

Official Helm Chart Repository for InfluxData Applications
MIT License
233 stars 329 forks source link

telegraf helm chart does not support defining constants for starlark processor in values files #598

Open passing opened 1 year ago

passing commented 1 year ago

given this minimal values.yaml file

config:
  aggregators:
  - starlark:
      source: "#"
      tagpass:
        my_tag: "hello"
      constants:
        my_constant: "hello"

rendering the template

helm repo add influxdata https://helm.influxdata.com/
helm template telegraf influxdata/telegraf --values values.yaml

the result includes the telegraf ConfigMap with the starlark aggregator

    [[aggregators.starlark]]
      source = "#"
      [[aggregators.starlark.constants]]
        my_constant = "hello"
      [aggregators.starlark.tagpass]
        my_tag = "hello"

that configuration won't be accepted by telegraf

2023-08-30T09:38:14Z E! error loading config file /etc/telegraf/telegraf.conf: error parsing starlark, line 19: (starlark.Starlark.Constants) cannot unmarshal TOML array table into map[string]interface {} (need slice)

the template handles tagpass and tagdrop separately here to create TOML inline tables instead of arrays of tables, so this probably needs to be extended to support starlark constants: https://github.com/influxdata/helm-charts/blob/master/charts/telegraf/templates/_helpers.tpl#L464