influxdata / influxdata/telegraf
Give option to not append `name_prefix` if the metric name already begins with said prefix
- Dominant language
- Go
- Stars
- 17.8k
- Forks
- 5.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 161
Description
## Feature Request
### Proposal:
That Telegraf adds an option to inputs to avoid prefixing `name_prefix` if the metrics already begin with the prefix.
### Current behavior:
Telegraf does not have an option to avoid prefixing `name_prefix` when metrics already begin with the prefix.
### Desired behavior:
Telegraf has an option to avoid prefixing `name_prefix` when metrics already begin with the prefix.
### Use case:
Generally, I would appreciate this option as I find end-users misusing `name_prefix` for applications that already emit metrics with that prefix, e.g. `name_prefix = prometheus` for a Prometheus server producing `prometheus_prometheus.*`.
More importantly though, an end-user was observed misconfiguring their `telegraf.conf` such that the Prometheus input was scraping the Prometheus output client. Since they were using `name_prefix` on their input, which was in essence their output, it was essentially continually/recursively prefixing `name_prefix`. While other safeguards like sample limits can be and are in place, and while this is like a hella corner case, I would like to be able to protect against it in future. I happened to catch it on a spot check.
I'm happy to code this up if the proposal is accepted 👍
Contributor guide
Research direction
No files, tests, or entry points are named. Start by locating Telegraf's handling of input name_prefix and metric names, then determine where the option belongs and how existing configuration is tested. Done means an input can avoid adding name_prefix when the metric name already begins with it, including the described recursive-prefix case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100