spring-bootgrafanaprometheus

HTTP client request metrics prometheus grafana


I'm interesting to monitor an HTTP REST API that is used by my application.

Using spring boot, dropwizard and @EnablePrometheusEndpoint annot. I'm able to produce such prometheus metrics on /prometheus endpoint:

http_client_requests_method_GET_uri_api_v1_objects_status_200_count 3.0
http_client_requests_method_GET_uri_api_v1_objects_status_404_count 1.0

I would like to build in grafana a graph to display all the call for GET method on uri api_v1_objects with the different status code (one line for each status code).

Should I set the status code as a label of the metrics ? Does io.prometheus simpleclient lib allows to register dropwizard metrics with label ?

For the time being, when I define my graph, I need to statically define one line for each status code. This is not dynamic for new status code that could occur in the futur (500, etc.)

Thank in advance for your help.

Aurelien


Solution

  • Should I set the status code as a label of the metrics ?

    Would be the best idea IMO.

    Does io.prometheus simpleclient lib allows to register dropwizard metrics with label ?

    The problem is that DW does not handle labels very well.

    If you are using spring-boot I really suggest you to migrate to micrometer new metric framewok. It is the default for spring-boot 2 and it handles labels and other elements so it fits much better with promentheus than DW.