Skip to content

Kubernetes Metrics data sources

In a Kubernetes monitoring ecosystem, typically centered around tools like Prometheus, Metrics data is aggregated from various layers of the infrastructure to provide visibility into system health and performance^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]. These data sources are generally categorized into three main types: host-level Metrics, component-level Metrics, and core object metrics^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].

Host Metrics

The first layer of data sources involves the physical or virtual host machines. To gather these Metrics, monitoring solutions typically deploy an agent, such as the Node Exporter, onto each host^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]. This agent acts as a proxy, exposing hardware and OS-level Metrics (e.g., CPU, memory, disk I/O) in a format that can be scraped by the monitoring system^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].

Component Metrics

The second layer focuses on the internal components of Kubernetes itself, such as the API Server and Kubelet^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]. These components expose operational data through their respective /metrics APIs^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].

Beyond standard resource usage, these endpoints provide critical insights into the internal state of the cluster, such as: * Work Queue lengths for various controllers^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]. * Request QPS (Queries Per Second)^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]. * Latency data for API requests^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].

This data is essential for diagnosing issues within the control plane and ensuring the cluster management layer is functioning correctly^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].

Core Metrics (Kubernetes Objects)

The third layer covers the core Kubernetes objects, such as Pods, Nodes, Containers, and Services^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]. These data points are often referred to as Core Metrics^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].

Historically, tools like Heapster were used for this purpose, but the standard has shifted to Metrics Server^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]. Metrics Server is a cluster-wide aggregator of resource usage data that provides this information via the Kubernetes Metrics API, enabling features like the Horizontal Pod Autoscaler (HPA) and the kubectl top command^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].

Monitoring Methodologies

To effectively structure the Metrics collected from these sources, industry-standard methodologies are often applied^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]:

  • USE Method: Focuses on Resource monitoring. It targets Utilization (average time used), Saturation (congestion level), and Errors (count of errors)^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].
  • RED Method: Focuses on Service monitoring. It targets Rate (requests per second), Errors (errors per second), and Duration (service response time)^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md].

Sources

^[400-devops__06-Kubernetes__k8s-paas__原理及源码解析__Kubernetes相关生态.md]