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

Config file does not support valid comments within arrays #3642

Closed
dimas opened this issue Jan 5, 2018 · 4 comments
Closed

Config file does not support valid comments within arrays #3642

dimas opened this issue Jan 5, 2018 · 4 comments
Labels
area/configuration bug unexpected problem or unintended behavior

Comments

@dimas
Copy link

dimas commented Jan 5, 2018

Guys, I am Go-illiterate so I apologise in advance for the report which can be just "this is how it works in Go, deal with it".
But it feels a bit weird that you cannot comment properly in potentially long lists like templates of a socket_listener:

[[inputs.socket_listener]]
service_address = "tcp://:2003"
data_format = "graphite"
# The comment works here perfectly
templates = [
  # But this comment throws a "parse error"
  "aaa bbb"
]

telegraf 1.5.0

Interesting enough is the doc provides an example actually: https://github.com/influxdata/telegraf/blob/052e88ad5ea5fa5872fba8998f1bf819ce418acb/docs/DATA_FORMATS_INPUT.md

Multiple templates can also be specified, but these should be differentiated using filters (see below for more details)

templates = [
    "*.*.* region.region.measurement", # <- all 3-part measurements will match this one.
    "*.*.*.* region.region.host.measurement", # <- all 4-part measurements will match this one.
]

which does not work either:

2018/01/05 13:24:53 E! Error parsing /etc/telegraf/telegraf.d/graphite_input.conf, toml: line 16: parse error

where line 16 is this:

"*.*.*.* region.region.host.measurement", # <- all 4-part measurements will match this one.

and removing a comment on previous line fixes it

@danielnelson
Copy link
Contributor

The configuration file is a TOML file, you can find the specification here: https://github.com/toml-lang/toml

I believe these should be allowed by the TOML format, and is a bug in the library we are using to parse the config file. I am planning to switch to the BurntSushi library soon which handles both of these examples correctly for #1598 #272

@danielnelson danielnelson changed the title Support for comments in "lists" in config file Config file does not support valid comments within arrays Jan 5, 2018
@danielnelson danielnelson added bug unexpected problem or unintended behavior area/configuration labels Jan 5, 2018
@clarsen
Copy link

clarsen commented May 22, 2020

FYI, does not appear to work in as of telegraf 1.14

@DavidAntliff
Copy link

DavidAntliff commented Aug 31, 2021

Just encountered this myself in telegraf 1.19.3 - according to the TOML spec comments in lists should be allowed.

https://toml.io/en/v1.0.0#comment

@sspaink
Copy link
Contributor

sspaink commented Apr 25, 2022

Closing in favor of: #10534 to track this issue, although this is an older issue I think the information in #10534 will be useful to help resolve this.

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

5 participants