How to capture metrics Separately for GET,POST and PUT method for given REST Endpoint using spring boot actuators.
Ex
by default we get :- "gauge.response.customer": 631, i need
Thanks in advance
Hmm I do not believe you can break the endpoints down like that. However, I do know that actuator is very flexible and you can add new metrics to that endpoint. It looks like you are interested primarily in counters so I would recommend using the CounterService that Spring boot has.
private CounterService counterService;
@Autowired
public MyClassName(CounterService counterService) {
this.counterService = counterService;
}
@RequestMapping(method=RequestMethod.POST)
public String myPostMethod(Object obj) {
counterService.increment("mycontroller.post.method");
//...
return "myPostMethod";
}
@RequestMapping(method=RequestMethod.GET)
public String myGetMethod() {
counterService.increment("mycontroller.get.method");
//...
return "myGetMethod";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.