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

Improve error handling of incorrect types in configuration #6474

Closed
adrianlzt opened this issue Oct 2, 2019 · 2 comments
Closed

Improve error handling of incorrect types in configuration #6474

adrianlzt opened this issue Oct 2, 2019 · 2 comments
Labels
area/configuration bug unexpected problem or unintended behavior

Comments

@adrianlzt
Copy link
Contributor

Feature Request

Telegraf silenty ignore parameters with incorrectly defined types.

In some configurations, this could lead to an unxpected behaviour with a solution difficult to be spotted.

Proposal:

Telegraf should fail if a parameter is defined with the incorrect type.

Current behavior:

If tagpass/tagdrop/namepass/namedrop/fieldpass/fielddrop is defined using the incorrect type, it is ignored

Desired behavior:

Refuse to start if the parameter is found with the incorrect type.

Use case:

Example with tagpass, defined as an array of tables instead of a table.
In this case tagpass will be ignored.

[agent]
  interval = "1s"
  flush_interval = "1s"

[[inputs.kernel]]

[[processors.printer]]
  [[processors.printer.tagpass]]  # THIS should be a table
    host = ["hostname"]

[[outputs.file]]
  files = ["out"]

If tagpass is not a table, there is not an else condition to return an error.

Same happens if we defined host as string.
In this case the host filter will be ignored.

[[processors.printer]]
  [processors.printer.tagpass]
    host = "hostname"   # THIS should be an array
@danielnelson
Copy link
Contributor

This is closely related to #3444, I believe to resolve we need to make the move to the github.com/BurntSushi/toml library for parsing the configuration file.

@powersj
Copy link
Contributor

powersj commented Aug 8, 2022

Hi,

It appears that the examples using tag pass as a string and not a slice now correctly fail with #8910:

2022-08-08T18:51:18Z E! [telegraf] Error running agent: Error loading config file config.toml: error parsing printer, line 8:{105 127}: found unexpected format while parsing "tagpass", expecting string array/slice format on each entry

Closing as fixed, but if we have missed something, please try with the latest telegraf, and provide an example and logs.

@powersj powersj closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants