I was able to reproduce this on HEAD and the underlying problem is caused due to this check:
https://github.com/elastic/beats/blob/master/metricbeat/autodiscover/builder/hints/metrics.go#L173
It can be reproduced as follows:
Come up with a pod spec that has two containers, one exposing port 8080 and one exposing no ports at all.
Have annotations like:
co.elastic.metrics/module: prometheus
co.elastic.metrics/hosts: ${data.host}:8080
This will cause the container to be polled twice as it gets discovered once because of the explicit port definition on the container spec of container 1. Secondly since container 2 has no port definition and there is a port defined on the annotation.
Temporary work around is to pin the annotation to a single container.
I was able to reproduce this on HEAD and the underlying problem is caused due to this check:
https://github.com/elastic/beats/blob/master/metricbeat/autodiscover/builder/hints/metrics.go#L173
It can be reproduced as follows:
Come up with a pod spec that has two containers, one exposing port 8080 and one exposing no ports at all.
Have annotations like:
This will cause the container to be polled twice as it gets discovered once because of the explicit port definition on the container spec of container 1. Secondly since container 2 has no port definition and there is a port defined on the annotation.
Temporary work around is to pin the annotation to a single container.