Telegraf output data formats
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.
How output plugins use serializers
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
Choosing an output approach
By destination
| 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 |
By metric type
Some metric types require state across collection intervals:
- Histograms accumulate observations into buckets
- Summaries track quantiles over a sliding window
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 metrics: Use
prometheus_clientinstead of the prometheus serializer
Available serializers
Binary
Use the binary output data format (serializer) to serialize Telegraf metrics into binary protocols using user-specified configurations.
Carbon2
Use the carbon2 output data format (serializer) to format and output Telegraf metrics as Carbon2 format.
CloudEvents
Use the cloudevents output data format (serializer) to format Telegraf metrics as CloudEvents in JSON format.
CSV
Use the csv output data format (serializer) to convert Telegraf metrics into CSV lines.
Graphite
Use the graphite output data format (serializer) to format and output Telegraf metrics as Graphite Message Format.
InfluxDB line protocol
Use the influx output data format (serializer) to format and output metrics as InfluxDB line protocol format.
JSON
Use the json output data format (serializer) to format and output Telegraf metrics as JSON documents.
MessagePack
Use the msgpack output data format (serializer) to convert Telegraf metrics into MessagePack format.
Prometheus
Use the prometheus output data format (serializer) to convert Telegraf metrics into Prometheus text exposition format.
Prometheus Remote Write
Use the prometheusremotewrite output data format (serializer) to convert Telegraf metrics into Prometheus protobuf format for remote write endpoints.
ServiceNow metrics
Use the nowmetric ServiceNow metrics output data format (serializer) to output Telegraf metrics as ServiceNow Operational Intelligence format.
Splunk metrics
Use the splunkmetric metric output data format (serializer) to output Telegraf metrics in a format that can be consumed by a Splunk metrics index.
Template
Use the template output data format (serializer) to format and output Telegraf metrics using custom Go templates.
Wavefront
Use the wavefront output data format (serializer) to convert Telegraf metrics into Wavefront data format.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Telegraf and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.