telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

processors.enum.mapping to be applied to multiple fields

Open djvanhelmond opened this issue 3 years ago • 4 comments

Feature Request

Proposal:

Make the [processors.enum.mapping] applicable to multiple fields.

Current behavior:

I query a device that gives me json with 8 values that are either "on" or "off". Currently I have to create an [processors.enum.mapping] per value.

[[processors.enum]] [[processors.enum.mapping]] field = "field_1" [processors.enum.mapping.value_mappings] off = 0 on = 1 [[processors.enum.mapping]] field = "field_2" [processors.enum.mapping.value_mappings] off = 0 on = 1 etc.

Desired behavior:

[[processors.enum.mapping]] field = ["field_1", "field_2"] [processors.enum.mapping.value_mappings] off = 0 on = 1

Use case:

It makes the telegraf config more readable and prevents discrepancies.

djvanhelmond avatar Mar 25 '22 10:03 djvanhelmond

This makes sense to me. I think we should leave the field setting as a single string for backward compatibility, but we could a another setting called fields that takes an array of strings like you proposed.

@djvanhelmond Would you like to put together a PR to make this change?

reimda avatar May 16 '22 18:05 reimda

@reimda I appreciate the confidence, but I'm not nearly skilled enough to code something up in Go that would be remotely acceptable.

djvanhelmond avatar May 17 '22 11:05 djvanhelmond