Skip to main content
100%

Sample Prometheus scrape config for obtianing metrics from Kubernetes pods via DNS & Headless Service

✓ Published0🌍 Public
JJoelBCarter
Last edited Oct 10, 2016
Created on Oct 10, 2016

This example shows a Prometheus configuration that discovers Kubernetes pod endpoints through DNS service discovery, enabling metric scraping without hardcoded addresses. The `prometheus.yml` scrape config uses `dns_sd_configs` to query a headless service name like `{headless-service-name}.default.svc.cluster.local` at a 15-second refresh interval. The `relabel_configs` block applies a regex replacement to the `__address__` label, stripping the DNS-provided port and substituting `{your_pod_port}` so Prometheus scrapes the correct port. It relies on Prometheus’ `dns_sd_configs` and `relabel_configs` features to bridge DNS resolution with scrape target addressing.

AI-generated description

Similar vizzes