简体   繁体   中英

How to capture metrics Separately for GET,POST and PUT method for given REST Endpoint using spring boot actuators

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

  1. "gauge.response.customer.GET": 631, OR "gauge.response.GET.customer": 631,
  2. "gauge.response.customer.POST": 1631, OR "gauge.response.POST.customer": 1631

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM