Scraping kube-dns for Metrics | Kubernetes and Prometheus

Scraping kube-dns for Metrics | Kubernetes and Prometheus

Background

I had installed Prometheus via the Helm Chart. Most everything worked great out of the box, but it failed to scrape /metrics on the kube-dns pods.

Problem

By default, the Prometheus Helm Chart will scrape kube-dns pods on port 53. Adding annotations, telling Prometheus to scrape and the port number, corrects this issue.

Fix

Locate the service object for kube-dns. Add these two annotations inside of the metadata section:

"annotations": {
  "prometheus.io/port": "9153",
  "prometheus.io/scrape": "true"
}