|
| 1 | +--- |
| 2 | +title: Node metrics data |
| 3 | +content_type: reference |
| 4 | +weight: 50 |
| 5 | +description: >- |
| 6 | + Mechanisms for accessing metrics at node, volume, pod and container level, |
| 7 | + as seen by the kubelet. |
| 8 | +--- |
| 9 | + |
| 10 | +The [kubelet](/docs/reference/command-line-tools-reference/kubelet/) |
| 11 | +gathers metric statistics at the node, volume, pod and container level, |
| 12 | +and emits this information in the |
| 13 | +[Summary API](https://github.com/kubernetes/kubernetes/blob/7d309e0104fedb57280b261e5677d919cb2a0e2d/staging/src/k8s.io/kubelet/pkg/apis/stats/v1alpha1/types.go). |
| 14 | + |
| 15 | +You can send a proxied request to the stats summary API via the |
| 16 | +Kubernetes API server. |
| 17 | + |
| 18 | +Here is an example of a Summary API request for a node named `minikube`: |
| 19 | + |
| 20 | +```shell |
| 21 | +kubectl get --raw "/api/v1/nodes/minikube/proxy/stats/summary" |
| 22 | +``` |
| 23 | + |
| 24 | +Here is the same API call using `curl`: |
| 25 | + |
| 26 | +```shell |
| 27 | +# You need to run "kubectl proxy" first |
| 28 | +# Change 8080 to the port that "kubectl proxy" assigns |
| 29 | +curl http://localhost:8080/api/v1/nodes/minikube/proxy/stats/summary |
| 30 | +``` |
| 31 | + |
| 32 | +{{< note >}} |
| 33 | +Beginning with `metrics-server` 0.6.x, `metrics-server` queries the `/metrics/resource` |
| 34 | +kubelet endpoint, and not `/stats/summary`. |
| 35 | +{{< /note >}} |
| 36 | + |
| 37 | +## Summary metrics API source {#summary-api-source} |
| 38 | + |
| 39 | +By default, Kubernetes fetches node summary metrics data using an embedded |
| 40 | +[cAdvisor](https://github.com/google/cadvisor) that runs within the kubelet. |
| 41 | + |
| 42 | +## Summary API data via CRI {#pod-and-container-stats-from-cri} |
| 43 | + |
| 44 | +{{< feature-state for_k8s_version="v1.23" state="alpha" >}} |
| 45 | + |
| 46 | +If you enable the `PodAndContainerStatsFromCRI` |
| 47 | +[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) in your |
| 48 | +cluster, and you use a container runtime that supports statistics access via |
| 49 | +{{< glossary_tooltip term_id="cri" text="Container Runtime Interface">}} (CRI), then |
| 50 | +the kubelet fetches Pod- and container-level metric data using CRI, and not via cAdvisor. |
| 51 | + |
| 52 | +## {{% heading "whatsnext" %}} |
| 53 | + |
| 54 | +The task pages for [Troubleshooting Clusters](/docs/tasks/debug/debug-cluster/) discuss |
| 55 | +how to use a metrics pipeline that rely on these data. |
0 commit comments