1
votes

I want to statistics API requests in my Spring Boot 2 application,

Total number of requests processed

Total number of requests resulted in an OK response

Total number of requests resulted in a 4xx response

Total number of requests resulted in a 5xx response

Average response time of all requests

Max response time of all requests

I want to use Spring Boot Actuator and Micrometer, specifically, actuator/metrics/http.server.requests

But I have issues working with tag, Do I need any special configuration for the tag working? Thanks in advance.

enter image description here

enter image description here

enter image description here


UPDATE:

Finally, Both http://localhost:8080/travel/actuator/metrics/http.server.requests?tag=uri:/test/1 and http://localhost:8080/travel/actuator/metrics/http.server.requests?tag=status:200 work, by removing the second context path, /travel.

1
You can use Spring Boot Admin or can make a request with localhost:8889/actuator/metrics/http.server.requests?tag=uri:/endpoint&tag=status:200 See Metrics Collection for Spring Boot REST APIs - Romil Patel
Thanks for your help, but do I need special configuration for the tag working? {url}/actuator/metrics/http.server.requests works for me. But neither {url}/actuator/metrics/http.server.requests?tag=status:200 or {url}/actuator/metrics/http.server.requests?tag=uri:/test/1 work. Just get "This localhost page can’t be found" error. - Vikki
Hello @Vicky first make a request at that endpoint which should return 200 OK. Then make request to http.server.requests as it only shows the request which has been made. Or use the spring boot admin. Let me know if you face an issue - Romil Patel
Hi, thanks for your help, I made a request with 200, but still face the same issue, I edited the question with the screenshots. - Vikki
Try for .../http.server.requests?tag=uri:/test/1? - Romil Patel

1 Answers

2
votes

While making a request to /http.server.requests which only requires the endpoint of API to get the metrics for the particular endpoint.

As the application has a context path defined as the i.e /travel which is only required for making a request to endpoints.

Will work fine

http://localhost:8080/travel/actuator/metrics/http.server.requests?tag=uri:/test/1

do not work because of the context path in tag=uri

http://localhost:8080/travel/actuator/metrics/http.server.requests?tag=uri:/travel/test/1