Hello,
Context
I am working on a starlark processor script to make telegraf instances communicate and function like a cluster with HA-groups. More info in this topic.
I have a working concept where I can tag or drop metrics based on the state of the instance in the HA-group.
But this is only able to tag or drop metrics that have already been collected by an input plugin and having multiple instances request the same data can be problematic. For example, some modbus devices don’t like multuple masters requesting data. I can also imagine directory_monitor to be an issue, accessing and wanting to move the same file.
It would also reduce the network load to just stop collecting data if the instance is not responsible for a source at that time.
Required functionality
I would need all input plugins that work with a collection interval (modbus, directory_monitor, …) to act like a processor. This way it can be called conditionally when a “trigger metric” is passed in the processor. I can then create trigger using the mock input, pass it through the cluster processor and only if the telegraf instance is the master of the HA-group, pass it to processors.modbus to collect the data.
The output will just add (overwrite or add with prefix) fields and tags to the input metric.
For event based inputs this is not really relevant, because they often handle multiple client connections.
Usefull side effect
Making these inputs usable as processor would enable trigger based collection. For example depending on a OPCUA value change, SQL data can be requested adhoc and added to the original metric.
Implementation
It would be neat to have a single processor in which you can configure a complete input plugin that runs once, by just calling the existing Gather function. Or leave the configuration as a separate input and allow calling the gather function of a specific existing configuration from inside the generic processor.
