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 configuration file in values.json generates incorrect telegraf.conf toml file #682

Open
jminardi opened this issue Oct 9, 2024 · 0 comments

Comments

@jminardi
Copy link

jminardi commented Oct 9, 2024

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:

    - 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:

[[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:

[[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant