Scrape Prometheus endpoints

Scrape applications and exporters that expose Prometheus /metrics endpoints, and write the metrics to InfluxDB 3. This example scrapes a node_exporter instance and an application endpoint.

Configuration

[[inputs.prometheus]]
  ## Endpoints to scrape on each collection interval.
  urls = [
    "http://node1.example.com:9100/metrics",
    "http://app1.example.com:8080/metrics"
  ]

  ## Metric layout. The plugin default is 1. Version 2 is recommended.
  metric_version = 2

  ## Tag metrics with the scraped URL.
  url_tag = "url"

[[outputs.influxdb_v3]]
  urls = ["http://localhost:8181"]
  token = "
AUTH_TOKEN
"
database = "
DATABASE_NAME
"

Replace the following:

  • AUTH_TOKEN: your InfluxDB authorization token
  • DATABASE_NAME: the database to write to

How it works

  • urls lists the endpoints to scrape. The plugin requests each one on the collection interval and parses the exposition-format response.
  • metric_version = 2 stores each Prometheus sample as a metric named prometheus, with labels as tags and the Prometheus metric name as the field key. This layout is sparse, works well with column-oriented destinations like InfluxDB 3, and round-trips cleanly if you later re-serialize metrics with the Prometheus output data format. The plugin’s default is 1 (dense layout: metric name as measurement, counter/gauge field names), kept for backward compatibility.
  • url_tag records which endpoint each metric came from.

Example output

prometheus,cpu=cpu0,mode=idle,url=http://node1.example.com:9100/metrics node_cpu_seconds_total=18472.1 1709572230000000000
prometheus,url=http://node1.example.com:9100/metrics node_memory_MemAvailable_bytes=5836500992 1709572230000000000
prometheus,method=GET,path=/api/orders,status=200,url=http://app1.example.com:8080/metrics http_requests_total=84721 1709572230000000000

Extend this example


Was this page helpful?

Thank you for your feedback!