content/telegraf/v1/data_formats/output/_index.md
Telegraf uses serializers to convert metrics into output data formats.
Many output plugins support the data_format option, which lets you choose
how metrics are formatted before writing.
When you configure data_format in an output plugin, Telegraf uses a serializer
to convert metrics into that format before writing.
The output plugin controls where data goes; the serializer controls how it's formatted.
Some output plugins support use_batch_format, which changes how the serializer
processes metrics.
When enabled, the serializer receives all metrics in a batch together rather than
one at a time, enabling more efficient encoding and formats that represent multiple
metrics as a unit (like JSON arrays).
[[outputs.file]]
files = ["stdout"]
## Output plugin option: process metrics as a batch
use_batch_format = true
## Serializer selection: format metrics as JSON
data_format = "json"
Output plugins that support use_batch_format:
file, http, amqp, kafka, nats, mqtt, exec, execd, remotefile
| Destination | Recommended Approach |
|---|---|
| Prometheus scraping | prometheus_client output plugin (exposes /metrics endpoint) |
| InfluxDB | influxdb or influxdb_v2 output plugin (native protocol) |
| Remote HTTP endpoints | http output + serializer |
| Files | file output + serializer |
| Message queues | kafka, nats, amqp + serializer |
Some metric types require state across collection intervals:
Serializers process each batch independently and cannot maintain this state. When a histogram or summary spans multiple batches, the serializer may produce incomplete or incorrect output.
For these metric types, use a dedicated output plugin that maintains state--for example:
prometheus_client
instead of the prometheus serializer{{< children >}}