Reputation: 12129
How do I view the number of hits a specific controller endpoint received in a day or x period.
I have quite a basic demo app. My controller looks like this.
@RestController
@RequestMapping("/person")
@RequiredArgsConstructor
public class PersonController {
private final PersonService personService;
@GetMapping(path = "all")
public List<Person> getAllPerson() {
return personService.getAllPersons();
}
// etc
I have configured prometheus and have it running.
As you can see I have a graph showing for total logback events.
What would the query look like if wanted to show number of times the GET http://localhost:8080/person/all
as hit.
Upvotes: 0
Views: 4147
Reputation: 2699
http_server_requests_seconds_count
or http_server_requests_seconds_sum
metrics will have the details needed.
For example,
http_server_requests_seconds_count{application="xyz",exception="None",method="GET",status="200",uri="/admin/info",} 94078.0
http_server_requests_seconds_sum{application="xyz",exception="None",method="GET",status="200",uri="/admin/info",} 96.108260294
Tip: If the prometheus management endpoint is enabled, the prometheus metrics can be viewed in http://example.com/{actuator|admin}/prometheus
Upvotes: 5