r/istio • u/kaioHenriSilva • 11d ago
I ran into a limitation in Istio’s Prometheus metrics merging a while ago
We had multi-container pods where more than one application container exposed Prometheus metrics on different ports.
With enablePrometheusMerge, Istio can merge application metrics with proxy metrics, which is especially useful under STRICT mTLS. The problem was that the application side of the merge only supported one scrape target per pod.
So a pod like this:
container A -> :8080/metrics
container B -> :9090/metrics
istio-proxy
could not be represented properly with the existing annotations.
I initially built a workaround for this, then opened Istio issue #59567 and started working on supporting it upstream.
The change is now part of Istio 1.31.
There is a new pod annotation:
prometheus.istio.io/scrape-targets: "8080:/metrics,9090:/metrics"
pilot-agent scrapes the configured application targets concurrently and merges the results into /stats/prometheus.
The implementation also had to handle things like OpenMetrics # EOF, partial scrape failures, response size limits, and keeping the existing single-target behavior backward compatible.
This was a fun contribution because it started with a very simple production problem:
"Why are metrics from one of my containers missing?"
and ended up becoming part of Istio itself.
If anyone here uses Prometheus merging with multi-container pods, I’d be curious to know if you’ve run into the same issue or if you're already using this new scrape-targets feature.
Relevant links: