0
votes

In my spring boot project I would like to keep count of how many times the rest api endpoint responded with status 200. The spring boot actuator metrics endpoint came close to solving this issue for me out of the box. However, the /metrics endpoint names provided the aggregate of responses by the endpoint method rather than each of the dynamic endpoints created through @PathVariable. For example: while I can get http://localhost:8084/myproject/actuator/metrics/http.server.requests?tag=status:200,uri:/api/users/{id}/books

I would like to do something like http://localhost:8084/myproject/actuator/metrics/http.server.requests?tag=status:200,uri:/api/users/1/books and http://localhost:8084/myproject/actuator/metrics/http.server.requests?tag=status:200,uri:/api/users/2/books and so on.

Is there an easy way to do this?

1

1 Answers

0
votes

You can roll your own WebMvcTagsProvider. That's the place where you can hook into the tag generation. Have a look at DefaultWebMvcTagsProvider to get insight on how it is done for the default behaviour.

A note: The default tagging is done on purpose the way it is to hinder metrics explosion, because every metric name + tag combination is a new metric. So be aware of that.