title: Templated URLs in Prometheus End Point with Jersey and Micrometer
body: <p>I am trying to integrate micrometer in a spring application built using Jersey REST. I am using Spring Boot 1.5.</p>
  
  <p>When I have a pure Spring REST APIs (using Spring Web Annotations), prometheus results are displayed as below</p>
  
  <pre><code>http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/v2/api/greeting/{name}",} 18.0
  http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/v2/api/greeting/{name}",} 0.39309228
  </code></pre>
  
  <p>But for the APIs built using Jersey, the prometheus metrics are not templated.</p>
  
  <pre><code>http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_1",} 1.0
  http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_1",} 0.043685372
  http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_2",} 1.0
  http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_2",} 0.006280183
  http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_3",} 1.0
  http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_3",} 0.006258448
  http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_4",} 1.0
  http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_4",} 0.006635791
  http_server_requests_seconds_count{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_5",} 1.0
  http_server_requests_seconds_sum{exception="None",method="GET",status="200",uri="/v1/api/greeting/Jersey_5",} 0.006313993
  </code></pre>
  
  <p>Looks like there is an open issue with micrometer listed at <a href="https://github.com/micrometer-metrics/micrometer/issues/486" rel="nofollow noreferrer">https://github.com/micrometer-metrics/micrometer/issues/486</a> which causes this issue with jersey. A remedy is mentioned at <a href="https://github.com/micrometer-metrics/micrometer/issues/486#issuecomment-372446968" rel="nofollow noreferrer">https://github.com/micrometer-metrics/micrometer/issues/486#issuecomment-372446968</a>. When I add spring.jersey.type=filter, none of the actuator APIs work. Neither prometheus end point works.</p>
  
  <p>I do not want un-templated URLs appearing in Prometheus end point. Since my API can have infinitely many combinations (many names in above examples), it will create large metrics data and in turn prometheus server will have tones of metrics.</p>
  
  <p>Any help here is highly appreciated.</p>