influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.58k stars 5.56k forks source link

Error parsing opcua_listener monitoring params #15252

Closed JeroenVanHoye closed 5 months ago

JeroenVanHoye commented 5 months ago

Relevant telegraf.conf

# Retrieve data from OPCUA devices
[[inputs.opcua_listener]]
  name = "WZI"
  endpoint = "opc.tcp://10.0.0.53:4840"
  connect_timeout = "10s"
  connect_fail_behavior = "retry"
  request_timeout = "5s"
  security_policy = "None"
  security_mode = "None"
  auth_method = "Anonymous"
  username = "installer"
  password = "Inst@ller1"
  timestamp = "gather"
  timestamp_format = ""

  client_trace = false

[[inputs.opcua_listener.group]]
  name = "08TT20305"
  namespace = "2"
  identifier_type = "s"
  default_tags = {tank = "F08200"}
  sampling_interval = "1s"

  nodes = [
    {name="Val_PV",         identifier="0:08TT20305.HMI.Val_PV",        monitoring_params={sampling_interval="0s", queue_size=10, discard_oldest=true, data_change_filter={trigger="Status", deadband_type="Absolute", deadband_value=0.0}}},
    {name="Val_PVNotSim",   identifier="0:08TT20305.HMI.Val_PVNotSim",  monitoring_params={sampling_interval="0s", queue_size=10, discard_oldest=true, data_change_filter={trigger="Status", deadband_type="Absolute", deadband_value=0.0}}},
    {name="Cfg_PVMax",      identifier="0:08TT20305.HMI.Cfg_PVMax",     monitoring_params={sampling_interval="0s", queue_size=10, discard_oldest=true, data_change_filter={trigger="Status", deadband_type="Absolute", deadband_value=0.0}}},
    {name="Cfg_PVMin",      identifier="0:08TT20305.HMI.Cfg_PVMin",     monitoring_params={sampling_interval="0s", queue_size=10, discard_oldest=true, data_change_filter={trigger="Status", deadband_type="Absolute", deadband_value=0.0}}},
  ]

Logs from Telegraf

C:\Users\developer>"c:\Program Files\telegraf\telegraf.exe" --config "c:\Program Files\telegraf\telegraf.conf" --config-directory "c:\Program Files\telegraf\telegraf.d" --debug
2024-04-29T08:35:15Z I! Loading config: c:\Program Files\telegraf\telegraf.conf
2024-04-29T08:35:15Z I! Loading config: c:\Program Files\telegraf\telegraf.d\OPCUA_WZI\Begin.conf
2024-04-29T08:35:15Z E! error loading config file c:\Program Files\telegraf\telegraf.d\OPCUA_WZI\Begin.conf: error parsing opcua_listener, line 50: (input.NodeSettings.MonitoringParams) cannot unmarshal TOML array table into input.MonitoringParameters (need slice)

System info

Telegraf v1.30.1, Windows Server 2022

Docker

No response

Steps to reproduce

1.add monitoring params from the example configuration to a node 2.run the configuration 3. ...

Expected behavior

Run with no errors

Actual behavior

Throws an arror about nog being able to unmarchal the TOML array

Additional info

Config works without these optional parameters. But I would like to configure the dead band. Would be nice to configure these parameters as a group settings as well instead of having to repeat it in each node.

srebhan commented 5 months ago

@JeroenVanHoye thank you very much for reporting this issue. It seems like the current parser cannot handle the inline notation for nested structs. PR #15261 removes the misleading configuration example... To solve your issue, you need to use the explicit notation

[[inputs.opcua]]
  ...
  [[inputs.opcua_listener.group]]
    name = "08TT20305"
    namespace = "2"
    identifier_type = "s"
    default_tags = {tank = "F08200"}
    sampling_interval = "1s"

  [[inputs.opcua_listener.group.nodes]]
    name = "Val_PV"
    identifier = "0:08TT20305.HMI.Val_PV"
    monitoring_params = {sampling_interval="0s", queue_size=10, discard_oldest=true, data_change_filter={trigger="Status", deadband_type="Absolute", deadband_value=0.0}}

  [[inputs.opcua_listener.group.nodes]]
    name = "Val_PVNotSim"
    identifier = "0:08TT20305.HMI.Val_PVNotSim"
    monitoring_params = {sampling_interval="0s", queue_size=10, discard_oldest=true, data_change_filter={trigger="Status", deadband_type="Absolute", deadband_value=0.0}}

  ...