Search code examples
springspring-bootmetricsspring-boot-actuator

What is the unit for the Spring actuator http.server.requests statistic


I have service implemented with spring-boot-starter-2.0.0.RELEASE. I have enabled actuator metrics for it, however I cannot understand what units are the metrics presented in. Specifically, I am interested in the http.server.requests.

A sample output of the endpoint is:

{
    "name": "http.server.requests",
    "measurements": [
        {
            "statistic": "COUNT",
            "value": 2
        },
        {
            "statistic": "TOTAL_TIME",
            "value": 0.049653001
        },
        {
            "statistic": "MAX",
            "value": 0.040696019
        }
    ],
    "availableTags": [
        {
            "tag": "exception",
            "values": [
                "None"
            ]
        },
        {
            "tag": "method",
            "values": [
                "GET"
            ]
        },
        {
            "tag": "status",
            "values": [
                "200"
            ]
        }
    ]
}

Solution

  • As of now (Spring-Boot:2.0.0 and Micrometer:1.0.2) the unfortunate answer is: It depends.

    The /actuator/metrics endpoint is backed by the currently active MeterRegistry implementation in your application. This implementation defines the base-unit of time in which the timed information is presented. E.g. if you got micrometer-registry-prometheus in your classpath only, the /acturor/metrics endpoint will serve timing information in seconds. If you got e.g. micromter-registry-graphite, the endpoint will serve in milliseconds (It's backed by DropwizardMeterRegistry.). If you got no "special" MeterRegistry implementation attracted, the SimpleMeterRegistry will become the backing registry and will serve seconds.

    To make things a little worse, if you got multiple MeterRegistry implementations aboard, the first implementation registered with the CompositeMeterRegistry will be chosen as the backing implementation which serves the /actuator/metrics endpoint.

    Disclaimer: The information has been collected from/with jkschneider, the maintainer of Micrometer.