influxdata / influxdata/helm-charts

telegraf configuration file in values.json generates incorrect telegraf.conf toml file

Open
#682 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Mustache
Stars
257
Forks
347
Avg merge
4d 20h
Merged PRs (30d)
9

Description

I am using the helm chart to deploy telegraf. I configure my telegraph instance via the values.yaml file. Here is my inputs section of the values.yaml configuration:
```yaml
- opcua:
name: "opcua_simulator"
endpoint: "opc.tcp://insights-opcua-simulator.insights-preproduction.svc.cluster.local:46010"
connect_timeout: "10s"
security_policy: "None"
security_mode: "None"
auth_method: "Anonymous"
nodes:
- name: "ConcentrationNH3"
namespace: "2"
identifier_type: "s"
identifier: "ConcentrationNH3"
- name: "ConcentrationN2"
namespace: "2"
identifier_type: "s"
identifier: "ConcentrationN2"
- name: "ConcentrationH2"
namespace: "2"
identifier_type: "s"
identifier: "ConcentrationH2"
- name: "Pressure"
namespace: "2"
identifier_type: "s"
identifier: "Pressure"
```

That produces the following toml file (found in the telegraf configmap:
```toml
[[inputs.opcua]]
auth_method = "Anonymous"
connect_timeout = "10s"
endpoint = "opc.tcp://insights-opcua-simulator.insights-preproduction.svc.cluster.local:46010"
name = "opcua_simulator"
[[inputs.opcua.nodes]]
identifier = "ConcentrationNH3"
identifier_type = "s"
name = "ConcentrationNH3"
namespace = "2"
[[inputs.opcua.nodes]]
identifier = "ConcentrationN2"
identifier_type = "s"
name = "ConcentrationN2"
namespace = "2"
[[inputs.opcua.nodes]]
identifier = "ConcentrationH2"
identifier_type = "s"
name = "ConcentrationH2"
namespace = "2"
[[inputs.opcua.nodes]]
identifier = "Pressure"
identifier_type = "s"
name = "Pressure"
namespace = "2"
security_mode = "None"
security_policy = "None"
```

Notice how the `security_mode` and `security_policy` fields are placed _after_ the nodes sections? This causes telegraf to crash with the following error:
```
2024-10-09T02:52:08Z I! Loading config: /etc/telegraf/telegraf.conf
2024-10-09T02:52:08Z E! loading config file /etc/telegraf/telegraf.conf failed: plugin inputs.opcua: line 32: configuration specified the fields ["request_timeout" "security_mode" "security_policy"], but they were not used. This is either a typo or this config option does not exist in this version.
```

If I manually update the configmap to put the fields above the nodes section, then telegraf will boot normally:
```toml
[[inputs.opcua]]
auth_method = "Anonymous"
connect_timeout = "10s"
endpoint = "opc.tcp://insights-opcua-simulator.insights-preproduction.svc.cluster.local:46010"
name = "opcua_simulator"
security_mode = "None"
security_policy = "None"
[[inputs.opcua.nodes]]
identifier = "ConcentrationNH3"
identifier_type = "s"
name = "ConcentrationNH3"
namespace = "2"
[[inputs.opcua.nodes]]
identifier = "ConcentrationN2"
identifier_type = "s"
name = "ConcentrationN2"
namespace = "2"
[[inputs.opcua.nodes]]
identifier = "ConcentrationH2"
identifier_type = "s"
name = "ConcentrationH2"
namespace = "2"
[[inputs.opcua.nodes]]
identifier = "Pressure"
identifier_type = "s"
name = "Pressure"
namespace = "2"
```

I don't know enough about `toml` to understand why the keys can't be after the nodes sections. But it does seem like the keys are sorted alphabetically before generating the toml. If that step could be skipped then we could work around this issue.

Contributor guide

Open the contributing guide

Research direction

Start with values.yaml and the chart's ConfigMap rendering that produces telegraf.conf; reproduce the OPC UA input with nested nodes and inspect how TOML sections are ordered. The fix is complete when security_mode and security_policy remain part of inputs.opcua before the nodes sections and Telegraf loads the generated configuration successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.