Kubeletstats Receiver
contrib, k8s
Maintainers: @TylerHelmuth, @ChrsMark, @dloucasfx, @jinja2
Source: opentelemetry-collector-contrib
Supported Telemetry
Overview
Metrics
Details about the metrics produced by this receiver can be found in metadata.yaml with further documentation in documentation.md.Node PID Metrics vs. Host Metrics
The optional metricsk8s.node.pid.usage and k8s.node.pid.limit are collected directly from Kubelet’s /stats/summary endpoint (NodeStats.Rlimit):
k8s.node.pid.usage: Reflects the total count of existing scheduling entities (threads and processes across all states) from/proc/loadavgon the node.k8s.node.pid.limit: Reflects the system-wide task limit (the lower ofkernel.pid_maxandkernel.threads-max) on the node.
hostmetricsreceiver / system.processes.*) in key ways:
- Permissions & Environment: They are retrieved through the Kubelet API without requiring
hostPID: true, privileged containers, or hostPath mounts (/proc,/sys), allowing collection in restricted or managed Kubernetes environments (such as GKE Autopilot). - Aggregation:
k8s.node.pid.usageis an aggregate number of allocated PIDs used by Kubelet for node PID eviction, rather than a per-state breakdown (e.g.running,sleeping,zombies). - PID Capacity Limit:
k8s.node.pid.limitexposes the node PID capacity limit (MaxPID), which is not provided byhostmetricsreceiver.
Compatibility
Kubernetes Versions
This receiver is tested against the Kubernetes versions specified in the e2e-tests.yml workflow. These tested versions represent the officially supported Kubernetes versions for this component.Configuration
A kubelet runs on a kubernetes node and has an API server to which this receiver connects. To configure this receiver, you have to tell it how to connect and authenticate to the API server and how often to collect data and send it to the next consumer. Kubelet Stats Receiver supports both secure Kubelet endpoint exposed at port 10250 by default and read-only Kubelet endpoint exposed at port 10255. Ifauth_type set to none, the read-only endpoint will be used. The secure
endpoint will be used if auth_type set to any of the following values:
tlstells the receiver to use TLS for auth and requires that the fieldsca_file,key_file, andcert_filealso be set.serviceAccounttells this receiver to use the default service account token to authenticate to the kubelet API along with the default certificate which is signed by the cluster’s root CA cert:/var/run/secrets/kubernetes.io/serviceaccount/token/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
kubeConfigtells this receiver to use the kubeconfig file (KUBECONFIG env variable or ~/.kube/config) to authenticate and use API server proxy to access the kubelet API.initial_delay(default =1s): defines how long this receiver waits before starting.
TLS Example
Service Account Authentication Example
Although it’s possible to use kubernetes’ hostNetwork feature to talk to the kubelet api from a pod, the preferred approach is to use the downward API. Make sure the pod spec sets the node name as follows:K8S_NODE_NAME environment variable:
endpoint will cause the hostname on which the
collector is running to be used as the endpoint. If the hostNetwork flag is
set, and the collector is running in a pod, this hostname will resolve to the
node’s network namespace.
Custom CA
The service account client, by default, uses the CA certificate located at/var/run/secrets/kubernetes.io/serviceaccount/ca.crt to validate the kubelet certificate.
If the kubelet server uses a certificate issued by a different CA,
specify the custom CA certificate path using the ca_file option.
AKS Custom CA example
This use case applies to AKS cluster, where the kubelet certificate is issued by/etc/kubernetes/certs/kubeletserver.crt
Read Only Endpoint Example
The following config can be used to collect Kubelet metrics from read-only endpoint:Kubeconfig example
The following config can be used to collect Kubelet metrics from read-only endpoint, proxied by the API server:auth_type kubeConfig, the endpoint should only be the node name as the communication to the kubelet is proxied by the API server configured in the kubeConfig.
insecure_skip_verify still applies by overriding the kubeConfig settings.
If no context is specified, the current context or the default context is used.
Extra metadata labels
By default, all produced metrics get resource labels based on what kubelet /stats/summary endpoint provides. For some use cases it might be not enough. So it’s possible to leverage other endpoints to fetch additional metadata entities and set them as extra labels on metric resource. Currently supported metadata include the following:container.id- to augment metrics with Container ID label obtained from container statuses exposed via/pods.k8s.volume.type- to collect volume type from the Pod spec exposed via/podsand have it as a label on volume metrics.
container.id label added to your metrics, use extra_metadata_labels field to enable
it, for example:
extra_metadata_labels is not set, no additional API calls is done to fetch extra metadata.
Collecting Additional Volume Metadata
When dealing with Persistent Volume Claims, it is possible to optionally sync metdadata from the underlying storage resource rather than just the volume claim. This is achieved by talking to the Kubernetes API. Below is an example, configuration to achieve this.k8s_api_config is set, the receiver will attempt to collect metadata from underlying storage resources for
Persistent Volume Claims. For example, if a Pod is using a PVC backed by an EBS instance on AWS, the receiver
would set the k8s.volume.type label to be awsElasticBlockStore rather than persistentVolumeClaim.
Important: When using k8s_api_config, the service account must have get permissions for
persistentvolumeclaims and persistentvolumes resources. See Role-based access control
for the required RBAC configuration.
Metric Groups
A list of metric groups from which metrics should be collected. By default, metrics from containers, pods and nodes will be collected. Ifmetric_groups is set, only metrics from the listed groups
will be collected. Valid groups are container, pod, node and volume. For example, if you’re
looking to collect only node and pod metrics from the receiver use the following configuration.
Network metrics from all interfaces for Node and Pod
By default,k8s.[node|pod].network.* metrics are collected only for the default network interface (e.g. eth0). To enable network IO/error metrics collection from all available interfaces on Node/Pod level - you can use collect_all_network_interfaces configuration parameters. Please be aware that enabling this options will increase the amount of produced network metrics and increase network metrics cardinality, because of interface attribute.
For example, if you would like to have network IO/error metrics from all network interfaces for both Pod and Node level you can use the following configuration.
Collect k8s.{container,pod}.{cpu,memory}.node.utilization as ratio of total node’s capacity
In order to calculate the k8s.container.cpu.node.utilization, k8s.pod.cpu.node.utilization,
k8s.container.memory.node.utilization and k8s.pod.memory.node.utilization metrics, the
information of the node’s capacity must be retrieved from the k8s API. In this, the k8s_api_config needs to be set.
In addition, the node name must be identified properly. The K8S_NODE_NAME env var can be set using the
downward API inside the collector pod spec as follows:
node value to ${env:K8S_NODE_NAME} in the receiver’s configuration:
Deprecation notice: Thek8s.container.cpu.node.utilization,k8s.pod.cpu.node.utilization,k8s.container.memory.node.utilization, andk8s.pod.memory.node.utilizationmetrics are deprecated. They calculate utilization relative to total node capacity. Consider using the corresponding CPU or memory usage metrics together withk8s.node.allocatable_cpuork8s.node.allocatable_memory, as appropriate. These alternatives use allocatable capacity and do not produce an equivalent node-capacity-based utilization value.
Optional parameters
The following parameters can also be specified:collection_interval(default =10s): The interval at which to collect data.insecure_skip_verify(default =false): Whether or not to skip certificate verification.
Configuration Options Reference
The Kubelet Stats Receiver supports the following configuration options. Options inherited from the Collector’s scraper, network, kubelet client, and metric-builder configuration are included where applicable. See config.go and the referenced configuration definitions for implementation details.
Some options are inherited from the Collector’s scraper, network, kubelet client, and metric-builder configuration structs. Consult config.go and the linked configuration definitions for the complete inherited option set.
Role-based access control
The Kubelet Stats Receiver needsget permissions on the nodes/stats resources. Additionally, when using extra_metadata_labels or any of the {request|limit}_utilization metrics the receiver also needs get permissions for nodes/pods resources.
When using k8s_api_config to collect detailed volume metadata from PersistentVolumeClaims (as described in Collecting Additional Volume Metadata), the receiver also needs get permissions for persistentvolumeclaims and persistentvolumes resources.
Feature Gates
See documentation.md for the feature gates supported by this receiver.receiver.kubeletstats.cpuUsageScrapeBased
This feature gate controls how the receiver calculates CPU usage for
container.cpu.usage, k8s.pod.cpu.usage, and k8s.node.cpu.usage,
along with CPU utilization metrics derived from them.
When enabled, the receiver calculates CPU usage from the rate of the
corresponding cumulative CPU-time counter between consecutive scrapes.
When disabled, the receiver uses the CPU usage reported by kubelet through
UsageNanoCores.
The scrape-based calculation maintains previous CPU-time samples in memory.
A usage value cannot be calculated for a resource until a previous valid
sample is available. After a Collector restart, the baseline is rebuilt
from subsequent scrapes.
This feature gate is at the beta stage and is enabled by default. To disable
it and use the CPU usage reported by kubelet, start the Collector with:
Self-observability
The Kubelet Stats Receiver does not expose component-specific internal telemetry of its own. It uses the Collector’s standard receiver and scraper observability mechanisms. Theotelcol_scraper_scraped_metric_points and
otelcol_scraper_errored_metric_points metrics provide information about
scraped metric points and scraping errors, respectively.
Failures when requesting the kubelet /stats/summary or /pods endpoints
are reported through the scraping operation and Collector logs. Use the
Collector’s internal telemetry and logs to monitor receiver activity and
investigate scraping failures.
For details on configuring and monitoring Collector internal telemetry,
see the Collector internal telemetry documentation.
Graceful Shutdown and Statefulness
Whenreceiver.kubeletstats.cpuUsageScrapeBased is enabled, the receiver retains previous CPU-time samples in memory to calculate CPU usage from consecutive scrapes. These samples are transient calculation state and are not persisted across restarts.
After a Collector restart, the receiver needs to establish a new baseline from subsequent scrapes before it can calculate CPU usage. As a result, CPU usage values may be temporarily unavailable.
The receiver does not require persistent storage to preserve these CPU-time samples, and persistent storage is not supported for this calculation state.
Deployment and scaling
The Kubelet Stats Receiver collects metrics by querying the kubelet associated with a Kubernetes node. For node-level collection in Kubernetes, a common deployment pattern is to run the OpenTelemetry Collector as a DaemonSet, with each Collector instance configured to scrape the kubelet on its own node. For Helm-based Kubernetes deployments, see the OpenTelemetry Kube Stack chart for deployment examples. A Collector DaemonSet is a common deployment pattern for scraping the kubelet on each node. Use the Kubernetes downward API to set theK8S_NODE_NAME environment variable to spec.nodeName, then configure the receiver endpoint to use that node name. See the Service Account Authentication Example for an example configuration.
When tuning collection for larger clusters, consider the following:
- Collection interval: A shorter
collection_intervalincreases how frequently the receiver queries kubelet endpoints. Choose an interval that balances monitoring requirements with the load generated by collection. - Additional metadata and resource utilization: Configuring
extra_metadata_labelscauses the receiver to fetch additional metadata from the kubelet/podsendpoint. Enabling any of the{request,limit}_utilizationmetrics also requires this endpoint to retrieve pod and container resource requests and limits. - Kubernetes API access: Configuring
k8s_api_configenables additional Kubernetes API lookups for features that require Kubernetes metadata, including detailed persistent-volume metadata and node-capacity information used by the deprecated node-utilization metrics. Thek8s.{container,pod}.{cpu,memory}.node.utilizationmetrics are deprecated. Prefer the corresponding CPU or memory usage metrics andk8s.node.allocatable_cpuork8s.node.allocatable_memory, as appropriate. These alternatives use allocatable capacity and are not equivalent to the deprecated node-capacity-based calculation. Configure the required permissions for the features you enable. - Network metric cardinality: By default, node and pod network metrics are collected only for the default network interface. Enabling
collect_all_network_interfacesincreases the number of emitted metrics and their cardinality because metrics include theinterfaceattribute. - Metric selection: Use
metric_groupsand the individual metric enablement settings to limit the telemetry emitted to what your monitoring requirements need.
Warnings
-
Read-only kubelet endpoint: When
auth_type: noneis configured and no endpoint is specified, the receiver may use the unauthenticated HTTP kubelet endpoint on port10255. This read-only port is deprecated and is disabled by default or unavailable in many Kubernetes distributions and managed environments. Its availability depends on your cluster configuration. Verify your distribution’s security requirements and prefer the secured kubelet endpoint. -
TLS certificate verification: Setting
insecure_skip_verify: truedisables verification of the kubelet server certificate chain and hostname. Avoid this setting in production when certificate verification can be configured. - Duplicate collection: Ensure that each kubelet is scraped by the intended Collector instance. Multiple Collectors scraping the same kubelet for the same metrics can produce duplicate telemetry.
-
Scrape-based CPU usage gaps: When
receiver.kubeletstats.cpuUsageScrapeBasedis enabled, CPU usage is calculated from consecutive CPU-time samples. A value may be unavailable on the first scrape for a resource, after a Collector restart, or after a container restart or CPU-time counter reset. A subsequent valid sample is needed before usage can be calculated again. -
Deprecated node-utilization metrics:
k8s.container.cpu.node.utilization,k8s.pod.cpu.node.utilization,k8s.container.memory.node.utilization, andk8s.pod.memory.node.utilizationare deprecated. Consider the corresponding CPU or memory usage metrics andk8s.node.allocatable_cpuork8s.node.allocatable_memory, as appropriate. These alternatives use allocatable capacity and are not equivalent to the deprecated node-capacity-based calculation.
Available Benchmarks
The Kubelet Stats Receiver is benchmarked as part of the Collector Contrib testbed load tests. The test scrapes a mock kubelet endpoint with increasing pod counts and records Collector CPU and memory consumption. Results are published on the Collector Contrib load-test benchmark dashboard. See the testbed benchmark for the workload and setup details.Metrics
Attributes
Resource Attributes
Configuration
Example Configuration
Last generated: 2026-11-09