springspring-bootmetricsspring-boot-actuator

HTTP metrics per endpoint uri in spring boot app


I have enabled actuator for my project. I am interested in metrics per endpoint uri in my application.

I have two endpoints / and /hello. When I visit /actuator/metrics/http.server.requests I get the following result:

{
  "name": "http.server.requests",
  "description": null,
  "baseUnit": "seconds",
  "measurements": [
    {
      "statistic": "COUNT",
      "value": 11
    },
    {
      "statistic": "TOTAL_TIME",
      "value": 0.07724317
    },
    {
      "statistic": "MAX",
      "value": 0.024692496
    }
  ],
  "availableTags": [
    {
      "tag": "exception",
      "values": [
        "None"
      ]
    },
    {
      "tag": "method",
      "values": [
        "POST",
        "GET"
      ]
    },
    {
      "tag": "uri",
      "values": [
        "/actuator/metrics/{requiredMetricName}",
        "/actuator/health",
        "/**",
        "/hello",
        "/"
      ]
    },
    {
      "tag": "outcome",
      "values": [
        "CLIENT_ERROR",
        "SUCCESS"
      ]
    },
    {
      "tag": "status",
      "values": [
        "404",
        "200"
      ]
    }
  ]
}

However I am interested in the metrics for each endpoint / and /hello, information such as average response time, max, min etc.

Is there a configuration parameter for this? Above only provides an aggregate metrics information. I would like to see each endpoints metris.


Solution

  • You can use tags to get aggregated results, for example, if you just want to get metrics for /hello you would request:

    /actuator/metrics/http.server.requests?tag=uri:/hello
    

    And you can combine tags, for example if you want to get metrics for all requests made to /hello that returned 200 you could request:

    /actuator/metrics/http.server.requests?tag=uri:/hello&tag=status:200