<p>I have a Prometheus custom exporter which scraps the metrics off an application pod within the same node. I want to use the url (dns) and not the ip address of the target application.</p>
<p>Each node in the cluster will have a deployment of 1 such application and 1 exporter. How does each exporter know the dns of its corresponding application pod?</p>
<p>The application nodes are name my-app-1, my-app-2, ...</p>

Vipul Nandan
<p>so I figured that you are trying to monitor your application by letting prometheus scrape a metrics exporter for it. this metrics exporter runs in another pod on the same cluster as your application pod does, but because the metrics exporter runs on another pod, it has to find the applications pod to be able to generate the metrics for it.</p>
<p>I propose that you follow the kubernetes sidecar pattern and let the metrics exporter run in the same pod as your applications container. this way you avoid the need to let the metrics exporter discover your applications pod because it already knows where it runs, because containers in the same pod discover each other via localhost and their individual ports. this way, you can always predict where your application runs and you can configure your metrics exporter reliably in the same way for each application pod.</p>
<p>check <a href="https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods</a> to see how containers in the same pod interact with each other and how the sidecar pattern works.</p>
