helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

[telegraf] Cannot use `starlark` script as it doesn't accept multipleline string under processors.starlark.source

Open hungran opened this issue 2 years ago • 0 comments

Gotta issue when trying to implement starlark processor with this instruction link

###Helm value:

config:
  processors:
    - enum:
        mapping:
          field: "status"
          dest: "status_code"
          value_mappings:
            healthy: 1
            problem: 2
            critical: 3
    - starlark:
        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

result in configmap:

   [[processors.starlark]]
      source = "def apply(metric):\n  if metric.name == \"prometheus_remote_write\":\n        for k, v in metric.fields.items():\n            metric.name = k\n            metric.fields[\"value\"] = v\n            metric.fields.pop(k)\n  return metric\n"
    

The issue I was thought it came from the template we had to wrapped by processor helm template function Should we go with this like we did for telegraf-ds https://github.com/influxdata/helm-charts/pull/239 I would like to work on this :)

hungran avatar Mar 10 '23 10:03 hungran