Micrometer plugin has uri=NOT_FOUND when using ContextPath
See original GitHub issueActual behavior (the bug)
The uri
value is NOT_FOUND
for Prometheus metric when using Micrometer plugin
jetty_server_requests_seconds_count{exception="Unknown",method="GET",outcome="SUCCESS",status="200",uri="NOT_FOUND",} 1.0
Expected behavior
The uri
should have the value of path invoked
e.g.
jetty_server_requests_seconds_count{exception="Unknown",method="GET",outcome="SUCCESS",status="200",uri="/user/:name",} 1.0
To Reproduce
import io.javalin.Javalin;
import io.javalin.plugin.metrics.MicrometerPlugin;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import io.prometheus.client.exporter.HTTPServer;
import java.io.IOException;
import java.net.InetSocketAddress;
/**
* Application
*/
public class App {
private static PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
private static PrometheusMeterRegistry prometheusRegistryContextPath = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
public static void main(String[] args) throws IOException {
// without context path
new HTTPServer(new InetSocketAddress(8089), prometheusRegistry.getPrometheusRegistry());
Javalin app = Javalin.create(config -> {
config.registerPlugin(new MicrometerPlugin(prometheusRegistry));
}).start(8080);
app.get("/user/:name", ctx -> {
ctx.status(200);
ctx.json("Hello " + ctx.pathParam("name"));
});
// with context path
new HTTPServer(new InetSocketAddress(9099), prometheusRegistryContextPath.getPrometheusRegistry());
Javalin appWithContext = Javalin.create(config -> {
config.contextPath = "/contextpath";
config.registerPlugin(new MicrometerPlugin(prometheusRegistryContextPath));
}).start(9090);
appWithContext.get("/user/:name", ctx -> {
ctx.status(200);
ctx.json("Hello " + ctx.pathParam("name"));
});
}
}
When using without context path, uri value is available
curl -v http://localhost:8080/user/abc
http://localhost:8089/
This one results in
jetty_server_requests_seconds_count{exception="Unknown",method="GET",outcome="SUCCESS",status="200",uri="/user/:name",} 1.0
When using with context path, uri value is not available
curl -v http://localhost:9090/contextpath/user/abc
http://localhost:8099/
This one results in
jetty_server_requests_seconds_count{exception="Unknown",method="GET",outcome="SUCCESS",status="200",uri="NOT_FOUND",} 1.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Micrometer plugin has uri=NOT_FOUND when using ...
Actual behavior (the bug) The uri value is NOT_FOUND for Prometheus metric when using Micrometer plugin ; Expected behavior. The uri should have...
Read more >SpringBoot adds context path to Actuator endpoints
Is there a way to tell the springboot to ignore appending context path to actuator endpoints (through DispatcherServlet or CXFServlet or ...
Read more >Spring Boot app metrics - with Prometheus and Micrometer
Metrics are one way to find out how your application is performing. In this article we'll find out more about metrics and how...
Read more >A simple way of using Micrometer, Prometheus and Grafana ...
“Micrometer is a dimensional-first metrics collection facade whose aim is to allow you to time, count, and gauge your code with a ...
Read more >32. Monitoring and management over HTTP
The default convention is to use the id of the endpoint as the URL path. For example, health is ... 32.2 Customizing the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tipsy Sorry, haven’t been able to look into this, I’ll see if I can find time in next few days to do a PR.
@tipsy Sorry, I wasn’t able to make time to help on this. Thank you for the fix. Unfortunately, I’m not working on this anymore so can’t help in testing the plugin as well. My apologies, and thanks again