influxdata / telegraf

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

Telegraf config doesn't accept single quotes for table keys #15928

Open cheshar opened 1 month ago

cheshar commented 1 month ago

Relevant telegraf.conf

[global_tags]
  Account = 'MyAccount'
  "Key1" = 'Value1'
  'my.key' = 'Value2'

[inputs]
[[inputs.cpu]]
...

Logs from Telegraf

2024-09-23T17:11:25Z I! Loading config: tgraf-test.conf
2024-09-23T17:11:25Z E! loading config file tgraf-test.conf failed: error parsing data: line 4: invalid TOML syntax

System info

Telegraf 1.32.0 (git: HEAD@dcfadf8b)

Docker

No response

Steps to reproduce

  1. Create the test config as provided
  2. Run command to start telegraf. Command: telegraf --config

Expected behavior

Telegraf should start without any error

Actual behavior

Telegraf throws invalid TOML config as error

Additional info

I've sample telegraf configuration that I'm using to start telegraf. Even though the configuration is a valid toml document, the telegraf doesn't seem to like it and keep complaining about the quotes around the table keys. I couldn't find any documentation around not being allowed to use quotes around the table keys. Is this a bug?

bazko1 commented 1 month ago

This is a problem with downstream library https://github.com/influxdata/toml which had last change 6 years ago. Probably it was written with respect to TOML v0.4.0 (Published on 2/12/2015) it seems that single quoted keys were introduced in version TOML v0.5.0 (Published on 7/10/2018).

cheshar commented 1 month ago

@bazko1 Is there a plan to fix this? I'm generating the telegraf config using the go-toml/v2 https://github.com/pelletier/go-toml package and it uses single quotes as default around the keys (as well as values). But telegraf doesn't like it so I've to resort to replacing all the single quotes to double as a workaround for now.

bazko1 commented 1 month ago

Well I don't know of any plan as I am not telegraf maintainer myself. Assessment would be required how difficult is it to replace current one with some never lib like go-toml and if licenses are compatible, but go-toml is MIT so it should be fine.

srebhan commented 1 month ago

@cheshar and @bazko1 we do have plans to revamp config parsing but currently we don't have the resources as this will touch essential parts of Telegraf...