<p>Hi All I'm working on designing a Kubernetes sidecar / Adapter pattern for the Spring Boot Application to export Prometheus metrics, I am aware that we can use maven dependency
<code>io.micrometer:micrometer-registry-prometheus</code> to expose Prometheus metrics directly. However, with my limited knowledge, I got to know adapter/sidecar patterns we can extend apps in Kubernetes without changing the code. Being new to the Kubernetes concept I am struggling to figure out whether it can be achieved to adapter/sidecar pattern or not.
With my research, I find out example to expose Elasticsearch Prometheus metrics using adapter pattern <a href="https://learnk8s.io/sidecar-containers-patterns" rel="nofollow noreferrer">example</a> where Elasticsearch does not support natively exporting Prometheus metrics.</p>
<p>I need help with the following points</p>
<ul>
<li>Since Spring Boot provides a way to export Prometheus metrics using a micrometer, is it the correct approach to use a sidecar/adapter pattern to export metrics?</li>
<li>if yes can you please guide me on how can we achieve this using the sidecar/adapter pattern in Kubernetes?</li>
<li>any example would be great help.</li>
</ul>

<p>One way of accomplishing this is using a solution such as Open-Telemetry. You can choose to auto-instrument your application using OTEL agents and corresponding collectors (that run as a side-car application)</p>
<p>An example of this for the Java Petstore is here : <a href="https://signoz.io/blog/opentelemetry-spring-boot/" rel="nofollow noreferrer">https://signoz.io/blog/opentelemetry-spring-boot/</a></p>
<p>While this is not for Prometheus , you get the idea of this. In place of the Signoz exporter here , you can export it to the Prometheus sink and auto instrument &amp; also trace your application</p>
