Prometheus input data format

Use the prometheus input data format to parse Prometheus text exposition format into Telegraf metrics.

The prometheus input plugin uses this parser internally to scrape endpoints. Use the parser directly with a listener plugin, such as http_listener_v2, to accept pushed Prometheus metrics in the style of a Pushgateway.

Configuration

[[inputs.http_listener_v2]]
  service_address = ":8080"
  paths = ["/metrics"]
  data_format = "prometheus"

  ## Use the timestamp from the parsed data (default) or the time of
  ## parsing.
  # prometheus_ignore_timestamp = false

  ## Metric layout to produce (see below).
  ## Use 1 when writing to InfluxDB 3.
  # prometheus_metric_version = 2

prometheus_ignore_timestamp

If true, the parser discards timestamps included in the source data and assigns the time of parsing instead.

Type: boolean
Default: false

prometheus_metric_version

Controls how Prometheus metrics translate to Telegraf metrics.

Type: integer (1 or 2)
Default: 2

  • 2: each Prometheus sample becomes a Telegraf metric named prometheus, labels become tags, and the field name is the Prometheus metric name. All metrics share one measurement, with a field for each Prometheus metric name.
  • 1: the Prometheus metric name becomes the Telegraf metric name, labels become tags, and values become fields named after the sample type. Each Prometheus metric gets its own measurement.

The right version depends on the destination you write to. Use 1 when writing to InfluxDB 3, where the version 2 layout produces a wide, sparse table. InfluxDB v2 and InfluxDB Cloud (TSM) accept either layout. Use 2 to match the layout that Flux prometheus.scrape() produces, or when round-tripping metrics back out of Telegraf with the Prometheus output data format. See Choose a metric version.

The OpenMetrics input data format shows a worked example of both layouts.


Was this page helpful?

Thank you for your feedback!