content/enterprise_influxdb/v1/supported_protocols/prometheus.md
{{% warn %}} Note: The Prometheus API Stability Guarantees states that remote read and remote write endpoints are features listed as experimental or subject to change, and thus considered unstable for 2.x. Any breaking changes will be included in the InfluxDB release notes. {{% /warn %}}
InfluxDB support for the Prometheus remote read and write API adds the following HTTP endpoints to InfluxDB:
/api/v1/prom/read/api/v1/prom/writeAdditionally, there is a /metrics endpoint configured to produce default Go metrics in Prometheus metrics format.
Create a database in your InfluxDB instance to house data sent from Prometheus.
In the examples provided below, prometheus is used as the database name, but
you're welcome to use the whatever database name you like.
CREATE DATABASE "prometheus"
To enable the use of the Prometheus remote read and write APIs with InfluxDB, add URL values to the following settings in the Prometheus configuration file:
The URLs must be resolvable from your running Prometheus server and use the port
on which InfluxDB is running (8086 by default).
Also include the database name using the db= query parameter.
remote_write:
- url: "http://localhost:8086/api/v1/prom/write?db=prometheus"
remote_read:
- url: "http://localhost:8086/api/v1/prom/read?db=prometheus"
If authentication is enabled on InfluxDB,
pass the username and password of an InfluxDB user with read and write privileges
using the u= and p= query parameters respectively.
remote_write:
- url: "http://localhost:8086/api/v1/prom/write?db=prometheus&u=username&p=password"
remote_read:
- url: "http://localhost:8086/api/v1/prom/read?db=prometheus&u=username&p=password"
Including plain text passwords in your Prometheus configuration file is not ideal. Unfortunately, environment variables and secrets are not supported in Prometheus configuration files. See this Prometheus issue for more information:
Support for environment variable substitution in configuration file
As Prometheus data is brought into InfluxDB, the following transformations are made to match the InfluxDB data structure:
value field key. It is always a float.# HELP and # TYPE lines are ignored.NaN,-Inf, and +Inf) rather than reject the entire batch.
[http] write-tracing = true), then summaries of dropped values are logged.204 is returned.# Prometheus metric
example_metric{queue="0:http://example:8086/api/v1/prom/write?db=prometheus",le="0.005"} 308
# Same metric parsed into InfluxDB
measurement
example_metric
tags
queue = "0:http://example:8086/api/v1/prom/write?db=prometheus"
le = "0.005"
job = "prometheus"
instance = "localhost:9090"
__name__ = "example_metric"
fields
value = 308
In InfluxDB v1.5 and earlier, all Prometheus data goes into a single measurement named
_and the Prometheus measurement name is stored in the__name__label. In InfluxDB v1.6 or later, every Prometheus measurement gets its own InfluxDB measurement.
{{% warn %}} This format is different than the format used by the Telegraf Prometheus input plugin. {{% /warn %}}