Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upScrape multiple containers in a kubernets pod #1864
Comments
This comment has been minimized.
This comment has been minimized.
|
Try the container role. |
This comment has been minimized.
This comment has been minimized.
|
For my pods I use the following relabeling to use annotations to set a non-default port in the target.
But for role: containers this doesn't work in case you want to target multiple containers in a single pod . I don't think kubernetes allows you to do annotations on the containers inside a pod, does it? Any idea on how to select another than the default lowest numerical port? |
This comment has been minimized.
This comment has been minimized.
|
Containers are un-labeled. However, all meta labels you get with pod discovery should remain available for each container. |
This comment has been minimized.
This comment has been minimized.
|
In https://coreos.com/blog/prometheus-and-kubernetes-up-and-running.html they use the endpoint to get to all the containers that expose a certain service. So it might make sense to label pods that expose a certain functionality like the haproxy exporter and access them through a headless service instead of using the container role. Any place I can find documentation on best practices for this? |
This comment has been minimized.
This comment has been minimized.
|
I used endpoint discovery in that case as it has been around longer. It's a more straightforward use-case and won't change much as we try to figure out more optimal approaches for container/pod discovery. For endpoint discovery, there's no access to pod-level labels though. |
This comment has been minimized.
This comment has been minimized.
|
Is there any reason we couldn't add pod-level labels to endpoint discovery? |
This comment has been minimized.
This comment has been minimized.
|
Yes, endpoints in the Kubernetes API have no notion of origin. It's just a list that is written to as pods belonging to a service come and go. They are not necessarily backed by a pod and can also be maintained by third party software. |
This comment has been minimized.
This comment has been minimized.
|
Does that stop us from having pod labels where they are available? I'd presume the vast majority will be pods. |
This comment has been minimized.
This comment has been minimized.
|
Yes, because the API gives us a plain list of addresses and nothing else, because that's what it is. |
This comment has been minimized.
This comment has been minimized.
|
As part of the change to not ignore unhealthy endpoints, we'll likely be working from the service definition rather than the endpoints provided. We'll have access to all the labels then. |
This comment has been minimized.
This comment has been minimized.
|
This enters the whole discussion how the next iteration of SD would look like and won't help this issue. |
This comment has been minimized.
This comment has been minimized.
|
That's merely how we have to fix the existing SD to have the right semantics, and would help here if the user were to add a headless service is the container role doesn't work for some reason. |
fabxc
added
kind/question
component/service discovery
labels
Aug 5, 2016
This comment has been minimized.
This comment has been minimized.
|
@fabxc this can be close now, right? |
fabxc
closed this
Nov 25, 2016
EdSchouten
referenced this issue
Apr 21, 2017
Closed
Need a way for user to specify container labels #26275
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 24, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
JorritSalverda commentedAug 1, 2016
With the prometheus.io/scrape and prometheus.io/port annotation you can indicate which port to scrape for metrics in a Kubernetes pod.
I'd like to be able to scrape multiple containers in a single pod. Is that possible?
For TLS termination I run HAProxy as a side container for which I export the stats using the exporter. But if the application itself is instrumented as well I'd like to be able to scrape both.