Provide guidelines for how to structure a processor config #4616
Labels
docs
Issues related to Telegraf documentation and configuration descriptions
pm/consumability
Improves ease of use experience for Telegraf users
rfc
Request for comment - larger issues that require clarification
size/s
1 day effort, great beginniner issue
Feature Request
A common task in a processor is to pick a tag, field or measurement, modify the key or the value, and save it over the old value or to a new field/tag. Now that we are beginning to build a library of utility processors of this style, I have noticed that the naming conventions and configuration style is not very uniform between them.
To come up with some guidelines and best practices, I did a survey of the plugins to see if we can take steps to unify their feel. This information when finalized should be included in the contributing documentation or on the wiki.
I primarily considered the following processors, the remaining processors cover other tasks and I don't think they need to be unified to the same degree:
I identified that we have two main styles for structuring the plugin configuration, I refer to them as tag/field tables and operation tables style below.
Tag/Field table configs have a subtable named tag/tags or field/fields:
Operation tables have a table named after the operation to perform:
The current breakdown between the styles is as such:
The two formats can be converted between simply, here is the rename
processor in both styles:
While today we have more plugins using tags/fields, I think the operation style config has a couple advantages:
No potential conflict with the
tags
option, which is not currently available on processors but I think this is only an oversight, and it would be nice to add. Would have a similar conflict with afields
option if/when this is added.Operation based tables allows for having operations that have different argument sets more easily and are checked for error automatically. This is because you can map each table to a different type in the plugin struct.
Proposal:
Use operation style subtables instead of tag/field/measurement subtables:
Refactor to operation style:
Perfect:
Naming fields
Several conventions have been suggested:
This is basically a matter of taste, so I'm just going to go with what looks best to me:
Select the tag, field, measurement using:
If overwrite of the old value is desired, don't include a destination field. To write to a new field or tag use
dest
.Examples
Remember that we aren't going to break compatiblity on already released plugins, so regex and converter are just examples oh how I would do it if writing it today.
Rename, enum are already merged for 1.8, I may update these before the release time permitting.
The text was updated successfully, but these errors were encountered: