Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Actuator 'http.server.requests' metric MAX time

I have a Spring Boot application and I am using Spring Boot Actuator and Micrometer in order to track metrics about my application. I am specifically concerned about the 'http.server.requests' metric and the MAX statistic:

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

            ]
        }
    ]
}

I suppose the MAX statistic is the maximum time of execution of a request (since I have made two requests, it's the the time of the longer processing of one of them).

Whenever I filter the metric by any tag, like localhost:9090/actuator/metrics?tag=status:200

{
        "name": "http.server.requests",
        "measurements": [
            {
                "statistic": "COUNT",
                "value": 1
            },
            {
                "statistic": "TOTAL_TIME",
                "value": 0.029653001
            },
            {
                "statistic": "MAX",
                "value": 0.0
            }
        ],
        "availableTags": [
            {
                "tag": "exception",
                "values": [
                    "None"
                ]
            },
            {
                "tag": "method",
                "values": [
                    "GET"
                ]
            }
        ]
    }

I am always getting 0.0 as a max time. What is the reason of this?

like image 370
Christina Avatar asked Jul 24 '18 13:07

Christina


1 Answers

  • What does MAX represent (MAX Discussion)

MAX represents the maximum time taken to execute endpoint.

Analysis for /user/asset/getAllAssets

COUNT  TOTAL_TIME  MAX
5      115         17
6      122         17  (Execution Time = 122 - 115 = 17)
7      131         17  (Execution Time = 131 - 122 = 17)
8      187         56  (Execution Time = 187 - 131 = 56)  
9      204         56  From Now MAX will be 56 (Execution Time = 204 - 187 = 17)  

  • Will MAX be 0 if we have less number of request (or 1 request) to the particular endpoint?

No number of request for particular endPoint does not affect the MAX (see an image from Spring Boot Admin)


  • When MAX will be 0

There is Timer which set the value 0. When the endpoint is not being called or executed for sometime Timer sets MAX to 0. Here approximate timer value is 2 to 2.30 minutes (120 to 150 seconds)

DistributionStatisticConfig has .expiry(Duration.ofMinutes(2)) which sets the some measutement to 0 if there is no request has been made for last 2 minutes (120 seconds)

Methods such as public TimeWindowMax(Clock clock,...), private void rotate() Clock interface has been written for the same. You may see the implementation here


  • How I have determined the timer value?

For that, I have taken 6 samples (executed the same endpoint for 6 times). For that, I have determined the time difference between the time of calling the endpoint - time for when MAX set back to zero


MAX property belongs to enum Statistic which is used by Measurement (In Measurement we get COUNT, TOTAL_TIME, MAX)

public static final Statistic MAX

The maximum amount recorded. When this represents a time, it is reported in the monitoring system's base unit of time.


Notes: This is the cases from metric for a particular endpoint (here /actuator/metrics/http.server.requests?tag=uri:/user/asset/getAllAssets).

For generalize metric of actuator/metrics/http.server.requests

MAX for some endPoint will be set backed to 0 due to a timer. In my view for MAX for /http.server.requests will be same as a particular endpoint.

enter image description here


UPDATE

The document has been updated for the MAX.

NOTE: Max for basic DistributionSummary implementations such as CumulativeDistributionSummary, StepDistributionSummary is a time window max (TimeWindowMax). It means that its value is the maximum value during a time window. If the time window ends, it'll be reset to 0 and a new time window starts again. Time window size will be the step size of the meter registry unless expiry in DistributionStatisticConfig is set to other value explicitly.

like image 131
Romil Patel Avatar answered Sep 22 '22 22:09

Romil Patel