Telegraf input data formats

Telegraf input plugins use parsers to convert incoming data into Telegraf metrics. Any input plugin that supports the data_format option can use it to select a parser:

[[inputs.file]]
  files = ["example.json"]

  ## Data format to consume.
  data_format = "json_v2"

Each parser has its own configuration options for describing your data’s schema and how it maps to metric names, tags, fields, and timestamps. For guidance on choosing and configuring a parser, including timestamp format reference and worked examples, see Parse incoming data.

Choose a JSON parser

Three parsers read JSON data. They differ in how much control they give you and how they handle nested structures:

ParserBest forValue selectionType control
jsonFlat objectsFlattens everything; optional GJSON json_queryNumbers only by default; strings and booleans via json_string_fields
json_v2Existing configurations that select nested valuesGJSON pathsPer-value type option
xpath_jsonNested documents and arrays; new configurationsXPath 1.0 queriesXPath conversion functions or native JSON types

We recommend xpath_json over json_v2 for new configurations, especially when working with arrays. Use json when your data is flat and you don’t need type control.

Available parsers


Was this page helpful?

Thank you for your feedback!