I have a RESTfull application written in Java 8 on Spring Boot 1.5.2.
I would like to collect statistics for the application usage, and i would like to get counters for tupples of (HTTP method, endpoint pattern, HTTP status).
I couldn't find an approach that covers my needs
Example
If my service receives 7 calls:
200 GET /user
400 POST /user
200 POST /user
200 GET /user/67
200 GET /user/90
200 GET /user/90/message
500 POST /user/90/message
I expect to collect:
GET /user 200 - 1
POST /user 400 - 1
POST /user 200 - 1
GET /user/{userId} 200 - 2
GET /user/{userId}/message 200 - 1
POST /user/{userId}/message 500 - 1
Possible approaches I've tried
Spring actuator metrics - Spring actuator collects data about method invocations and groups the counters by status.
Example:
{ "counter.status.200.user": 86, "counter.status.200.user.userId": 32, "counter.status.200.user.userId.message": 69 }
The drawbacks: HTTP method is not being grouped by the HTTP method
Spring filter - Found this Baeldung example that collects the metrics by the tupple (HTTP method, endpoint, HTTP status).
- The drawback: It uses the actual endpoint rather than the endpoint-pattern, which means that GET /user/1 and GET /user/2 will be counted separately.