Hello!
I have pods that have annotations containing the portNames that match the ports Prometheus should scrape per pod. I wanted to know if it is possible using the Kubernetes SD to relabel configs so that
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_portName]
action: drop
regex: __meta_kubernetes_pod_container_port_name
would only scrape the ports that have a specific portName defined in the annotations?
This workaround is introduced due to the condition that Prometheus creates a new target for each port that a container has while using the pod role in K8s SD whereas only one of them exposes Prometheus metrics.
So far I have tried different ways and I haven't found good documentation if it is possible to use labels in regex actions.
Thanks in advance,
Rasmus