3

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.

Romil Patel
  • 12,879
  • 7
  • 47
  • 76
Vikki
  • 1,897
  • 1
  • 17
  • 24
  • 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](https://stackoverflow.com/questions/56987541/metrics-collection-for-spring-boot-rest-apis) – Romil Patel Oct 06 '19 at 04:44
  • 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 Oct 06 '19 at 06:29
  • 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 Oct 06 '19 at 06:35
  • 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 Oct 06 '19 at 06:41
  • 1
    Try for `.../http.server.requests?tag=uri:/test/1`? – Romil Patel Oct 06 '19 at 08:17

1 Answers1

2

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

Romil Patel
  • 12,879
  • 7
  • 47
  • 76