Exposing metric path in container level

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version: 1.
Cloud being used: AWS

Is there anyway to expose the container metric path as an annotation within the pod? When we use kubernets_sd_config in prometheus, with pod as role, we get lot of container level annotations like this.

__meta_kubernetes_pod_container_init="false"
__meta_kubernetes_pod_container_name="example"
__meta_kubernetes_pod_container_port_name="web"
__meta_kubernetes_pod_container_port_number="9002"
__meta_kubernetes_pod_container_port_protocol="TCP"

I would like to get one more annotation like the one below.

__meta_kubernetes_pod_container_metric_path="/metrics"

This is currently unavailable now. I understand that Kubernetes may cannot understand in what path the metrics are exposing from a container. But it would be helpful if we could annotate for a container like we do it with kubernetes service.

This is helpful when we have multiple containers in a pod and and all are exposing metrics in a specific path. I know this can be achievable through multiple services but I would like to avoid deploying multiple services for a single pod, instead of if we have metric_path annotation with each container we can make use of it with pod service discovery in prometheus(which discovers all containers in a pod) with it’s own metric_path.

Thanks,

Hi:

You can annotate your pods with any information that you want/need: Annotations | Kubernetes

If I am not mistaken, annotations are defined at pod level; so if you have different paths for metric in each container, you can add one annotation for each container:

container_main_metrics_path="/metrics"
container_sidecar_metrics_path="/status"

Hope that it helps!

Best regards,

Xavi