Prometheus Remote Write input data format
Use the prometheusremotewrite input data format to parse
Prometheus Remote Write
samples into Telegraf metrics.
Use it with a listener plugin, such as
http_listener_v2, to
receive metrics pushed by Prometheus.
Configuration
[[inputs.http_listener_v2]]
## Address and port to host HTTP listener on
service_address = ":1234"
## Paths to listen to.
paths = ["/receive"]
## Data format to consume.
data_format = "prometheusremotewrite"
## Metric layout to produce (see below).
## Use 1 when writing to InfluxDB 3.
# prometheus_metric_version = 2prometheus_metric_version
Controls how Prometheus samples translate to Telegraf metrics.
Type: integer (1 or 2)
Default: 2
2: each sample becomes a Telegraf metric namedprometheus_remote_write, labels become tags, and the field name is the Prometheus metric name. All samples 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 the field is namedvalue. Each Prometheus metric gets its own measurement. Requires Telegraf 1.34 or later.
The right version depends on the destination you write to.
Use 1 when writing to InfluxDB 3, where the version 2 layout produces a
single wide, sparse prometheus_remote_write table with a column for every
metric name that Prometheus sends.
InfluxDB v2 and InfluxDB Cloud (TSM) accept either layout.
Use 2 to match the layout that Flux prometheus.scrape() produces.
See Choose a metric version.
Example Input
prompb.WriteRequest{
Timeseries: []*prompb.TimeSeries{
{
Labels: []*prompb.Label{
{Name: "__name__", Value: "go_gc_duration_seconds"},
{Name: "instance", Value: "localhost:9090"},
{Name: "job", Value: "prometheus"},
{Name: "quantile", Value: "0.99"},
},
Samples: []prompb.Sample{
{Value: 4.63, Timestamp: time.Date(2020, 4, 1, 0, 0, 0, 0, time.UTC).UnixNano()},
},
},
},
}Example Output (version 2, default)
prometheus_remote_write,instance=localhost:9090,job=prometheus,quantile=0.99 go_gc_duration_seconds=4.63 1614889298859000000Example Output (version 1)
go_gc_duration_seconds,instance=localhost:9090,job=prometheus,quantile=0.99 value=4.63 1614889298859000000Align with the InfluxDB v1.x Prometheus Remote Write spec
To align the output with the
InfluxDB v1.x Prometheus Remote Write spec,
use the
Starlark processor rename prometheus remote write script
to rename the measurement name to the field name and rename the field name
to value.
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.