I want to know if the apiserver_request_duration_seconds accounts the time needed to transfer the request (and/or response) from the clients (e.g. kubelets) to the server (and vice-versa) or it is just the time needed to process the request internally (apiserver + etcd) and no communication time is accounted for ?
As a plus, I also want to know where this metric is updated in the apiserver's HTTP handler chains ?
As an addition to the confirmation of @coderanger in the accepted answer. The metric is defined here and it is called from the function MonitorRequest which is defined here. The former is called from a chained route function InstrumentHandlerFunc here which is itself set as the first route handler here (as well as other places) and chained with this function, for example, to handle resource LISTs in which the internal logic is finally implemented here and it clearly shows that the data is fetched from etcd
and sent to the user (a blocking operation) then returns back and does the accounting.
How long API requests are taking to run. Whole thing, from when it starts the HTTP handler to when it returns a response.