influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.63k stars 5.58k forks source link

Batch format in exec/execd output #13654

Closed gazpachoking closed 1 year ago

gazpachoking commented 1 year ago

Use Case

Batch format changes the behavior of the json serializer. Currently 'exec' is hard coded to use batch format, and 'execd' is hard coded to not use it. This is confusing if the user switches from exec to execd or vice versa when using the json serializer, as the behavior changes unexpectedly (and isn't documented on the exec or execd readmes.) It also means the user doesn't have the option to select the other format if they wish.

Expected behavior

Actual behavior

'exec' is hard coded to use batch format, and 'execd' is hard coded to not use it.

Additional info

In addition to the json serializer, this would affect a possible template serializer #13637 (if it makes it in.)

powersj commented 1 year ago

Hi,

This is confusing if the user switches from exec to execd or vice versa

I do not believe there is a guarantee that these two plugins should behave the same. They fundamentally are different plugins, with different behavior.

That said, I do agree that we should consider an option which allows the plugin to write a batch at a time. Essentially changing the behavior of https://github.com/influxdata/telegraf/blob/master/plugins/outputs/execd/execd.go#L82 to write a batch at a time, rather than looping through each metric.

gazpachoking commented 1 year ago

I do not believe there is a guarantee that these two plugins should behave the same. They fundamentally are different plugins, with different behavior.

Yeah, that could be. I believe in execd plugin the end result would be exactly the same for all serializers except for Json, which has a different batch mode. I also realized it would be a breaking change if you were using Json serializer, so changing the defaults is probably not as good of an idea as I originally thought.

I think the other improvement would be to allow exec plugin to do a non-batch mode, which in my mind would call the executed program once per metric, rather than once per batch. So that would be a functional change no matter which serializer was used. I can look at adding these options next week for some more discussion.

powersj commented 1 year ago

Closed in #13673 and #13672