Skip to content

1.23.0 update broke XML input plugin: configuration specified the fields ["xml"], but they weren't used #11336

@phuntik

Description

@phuntik

Relevant telegraf.conf

[[inputs.exec]]
commands = [ "cat test.xml"]
data_format = "xml"

[[inputs.exec.xml]]
 [inputs.exec.xml.fields]
 nodes_configured = "number(//summary/nodes_configured/@number)"
 res_configured = "number(//summary/resources_configured/@number)"
 res_disabled = "number(//summary/resources_configured/@disabled)"
 res_blocked = "number(//summary/resources_configured/@blocked)"

Logs from Telegraf

$ telegraf --test --config debug.conf --debug
2022-06-21T14:14:52Z E! [telegraf] Error running agent: Error loading config file debug.conf: plugin inputs.exec: line 1: configuration specified the fields ["xml"], but they weren't used

System info

Telegraf 1.23.0, CentOS 7.9, Ubuntu 20.04

Docker

No response

Steps to reproduce

  1. Update to last Telegraf 1.23.0
  2. Take any xml file
  3. telegraf --test --config debug.conf --debug

Expected behavior

$ telegraf --test --config debug.conf 
2022-06-21T14:10:29Z I! Starting Telegraf 1.22.4
2022-06-21T14:10:29Z I! Loaded inputs: exec
2022-06-21T14:10:29Z I! Loaded aggregators: 
2022-06-21T14:10:29Z I! Loaded processors: 
2022-06-21T14:10:29Z W! Outputs are not used in testing mode!
> exec, nodes_configured=2,res_blocked=0,res_configured=4,res_disabled=0 1655820630000000000

Actual behavior

$ telegraf --test --config debug.conf --debug
2022-06-21T14:14:52Z E! [telegraf] Error running agent: Error loading config file debug.conf: plugin inputs.exec: line 1: configuration specified the fields ["xml"], but they weren't used

Additional info

  1. Originally using exec plugin for input to execute crm_mon command, behavior is same. For simplifying reproducing I used cat test.xml command.
    test.xml:
 <?xml version="1.0"?>
<crm_mon version="2.0.2">
    <summary>
        <nodes_configured number="2" />
        <resources_configured number="4" disabled="0" blocked="0" />
    </summary>
</crm_mon>
  1. Telegraf 1.22.4:
$ telegraf --test --config debug.conf 
2022-06-21T14:08:13Z I! Starting Telegraf 1.22.4
2022-06-21T14:08:13Z I! Loaded inputs: exec
2022-06-21T14:08:13Z I! Loaded aggregators: 
2022-06-21T14:08:13Z I! Loaded processors: 
2022-06-21T14:08:13Z W! Outputs are not used in testing mode!
> exec, nodes_configured=2,res_blocked=0,res_configured=4,res_disabled=0 1655820494000000000

All the same, just after updating to 1.23.0:

$ telegraf --test --config debug.conf --debug
2022-06-21T14:14:52Z E! [telegraf] Error running agent: Error loading config file debug.conf: plugin inputs.exec: line 1: configuration specified the fields ["xml"], but they weren't used
  1. Kinda same behavior happens if use file input plugin, but with no errors at least.
    Telegraf config with file input:
[[inputs.file]]
files = [ "test.xml"]
data_format = "xml"

[[inputs.file.xml]]
 [inputs.file.xml.fields]
 nodes_configured = "number(//summary/nodes_configured/@number)"
 res_configured = "number(//summary/resources_configured/@number)"
 res_disabled = "number(//summary/resources_configured/@disabled)"
 res_blocked = "number(//summary/resources_configured/@blocked)"

Telegraf 1.22.4:

$ telegraf --test --config debug.conf --debug
2022-06-21T14:18:04Z I! Starting Telegraf 1.22.4
2022-06-21T14:18:04Z I! Loaded inputs: file
2022-06-21T14:18:04Z I! Loaded aggregators: 
2022-06-21T14:18:04Z I! Loaded processors: 
2022-06-21T14:18:04Z W! Outputs are not used in testing mode!
2022-06-21T14:18:04Z D! [agent] Initializing plugins
2022-06-21T14:18:04Z D! [agent] Starting service inputs
2022-06-21T14:18:04Z D! [parsers.xml::file] Number of configs: 1
2022-06-21T14:18:04Z D! [parsers.xml::file] Number of selected metric nodes: 1
2022-06-21T14:18:04Z D! [agent] Stopping service inputs
2022-06-21T14:18:04Z D! [agent] Input channel closed
2022-06-21T14:18:04Z D! [agent] Stopped Successfully
> file, nodes_configured=2,res_blocked=0,res_configured=4,res_disabled=0 1655821085000000000

Telegraf 1.23.0:

$ telegraf --test --config debug.conf --debug
2022-06-21T14:15:23Z I! Starting Telegraf 1.23.0
2022-06-21T14:15:23Z I! Loaded inputs: file
2022-06-21T14:15:23Z I! Loaded aggregators: 
2022-06-21T14:15:23Z I! Loaded processors: 
2022-06-21T14:15:23Z W! Outputs are not used in testing mode!
2022-06-21T14:15:23Z D! [agent] Initializing plugins
2022-06-21T14:15:23Z D! [agent] Starting service inputs
2022-06-21T14:15:23Z D! [parsers.xml::file] Number of configs: 0
2022-06-21T14:15:23Z D! [agent] Stopping service inputs
2022-06-21T14:15:23Z D! [agent] Input channel closed
2022-06-21T14:15:23Z D! [agent] Stopped Successfully

So no errors, but no actual output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/execbugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions