feat(processors.enum): Allow mapping to be applied to multiple fields
Summary
Adds a new fields option to the enum processor, deprecating the old field option. Allows mapping multiple fields with one enum mapping when a glob does not work
Checklist
- [X] No AI generated code was used in this PR
Related issues
resolves #10892
Why don't we also make this change for tags at the same time as well?
I also think the previous behaviour is changed:
[[inputs.mock]]
metric_name = "mock"
[[inputs.mock.constant]]
name = "status"
value = "green"
[[inputs.mock.constant]]
name = "status_reverse"
value = "green"
[[processors.enum]]
[[processors.enum.mapping]]
field = "status"
[processors.enum.mapping.value_mappings]
green = 1
amber = 2
red = 3
[[processors.enum.mapping]]
field = "status_reverse"
[processors.enum.mapping.value_mappings]
green = 3
amber = 2
red = 1
Currently results in:
- > mock status="green",status_reverse="green"
+ > mock status=1i,status_reverse=3i
And I think with this PR, it will result in mock status=1i,status_reverse=1i.
@DStrand1 could you please test @Hipska's example (and ideally add it as a unit-test)!?
@DStrand1 do you have any update?
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. Downloads for additional architectures and packages are available below.
:relaxed: This pull request doesn't significantly change the Telegraf binary size (less than 1%)