Understanding Spring Boot actuator `http.server.requests` metrics MAX attribute

Rahul Gupta picture Rahul Gupta · Jul 12, 2019 · Viewed 7.2k times · Source

can someone explain what does the MAX statistic refers to in the below response. I don't see it documented anywhere.

localhost:8081/actuator/metrics/http.server.requests?tag=uri:/myControllerMethod

Response:

{  
   "name":"http.server.requests",
   "description":null,
   "baseUnit":"milliseconds",
   "measurements":[  
      {  
         "statistic":"COUNT",
         "value":13
      },
      {  
         "statistic":"TOTAL_TIME",
         "value":57.430899
      },
      {  
         "statistic":"MAX",
         "value":0
      }
   ],
   "availableTags":[  
      {  
         "tag":"exception",
         "values":[  
            "None"
         ]
      },
      {  
         "tag":"method",
         "values":[  
            "GET"
         ]
      },
      {  
         "tag":"outcome",
         "values":[  
            "SUCCESS"
         ]
      },
      {  
         "tag":"status",
         "values":[  
            "200"
         ]
      },
      {  
         "tag":"commonTag",
         "values":[  
            "somePrefix"
         ]
      }
   ]
}

Answer

buræquete picture buræquete · Jul 29, 2019

You can see the individual metrics by using ?tag=url:{endpoint_tag} as defined in the response of the root /actuator/metrics/http.server.requests call. The details of the measurements values are;

  • COUNT: Rate per second for calls.
  • TOTAL_TIME: The sum of the times recorded. Reported in the monitoring system's base unit of time
  • MAX: The maximum amount recorded. When this represents a time, it is reported in the monitoring system's base unit of time.

As given here, also here.


The discrepancies you are seeing is due to the presence of a timer. Meaning after some time currently defined MAX value for any tagged metric can be reset back to 0. Can you add some new calls to /myControllerMethod then immediately do a call to /actuator/metrics/http.server.requests to see a non-zero MAX value for given tag?

This is due to the idea behind getting MAX metric for each smaller period. When you are seeing these metrics, you will be able to get an array of MAX values rather than a single value for a long period of time.

You can get to see this in action within Micrometer source code. There is a rotate() method focused on resetting the MAX value to create above described behaviour.

You can see this is called for every poll() call, which is triggered every some period for metric gathering.