Plugin label cannot contain capitals
Relevant telegraf.conf
[[inputs.ping]]
[inputs.ping.labels]
key = "FOObar"
Logs from Telegraf
2025-12-09T11:42:24Z E! loading config file telegraf.conf failed: error parsing ping, invalid label in plugin inputs.ping: invalid value "FOObar"
System info
Telegraf 1.37.0
Docker
No response
Steps to reproduce
- Run
telegraf config check
Expected behavior
According to TSD-010, the labels and their value could contain capital letters.
Actual behavior
Telegraf errors out when using capital letters in key or value for a label.
Additional info
No response
cc @neelayu
Thanks @Hipska for the finding. I think there was some confusion initially as I had implemented the functionality before the spec was proposed and that implementation did not have uppercase characters.
We can fix it in the regex here https://github.com/influxdata/telegraf/blob/5e24958c0bc517f8deec205c98c379da39cbd505/config/plugin_selector.go#L17-L18
Also underscores do not work:
invalid label in plugin inputs.ping: invalid value "foo_bar"
Why are special chars not allowed as the first or last character? Otherwise the Regex could be more simple:
reKey = regexp.MustCompile(`^[\w\.\-]+$`)
reValue = regexp.MustCompile(`^\S+$`)
Actually we should keep it loosely consistent with https://datatracker.ietf.org/doc/html/rfc1123
contain at most 63 characters contain only lowercase alphanumeric characters or '-' start with an alphabetic character end with an alphanumeric character
But since we need characters like * and ? for values we have deviated slightly from that. These characters are wildcards for values.
I think we will have to revisit this again. Ideally we should have-
- start and end with alphanumeric
- can contain
-or_or.Values can contain the wildcard chars and should be non empty.
I don't see what these label keys or values have anything to do with internet hosts. I feel like its limiting too much without any technical reason..
I don't feel like #18108 completely resolved this issue, see my comments.
Current nightly builds accepts this label:
[[inputs.ping]]
[inputs.ping.labels]
key = "FOObar?*"
@Hipska that is correct. As you rightly pointed out, I missed calling the function. 🥹