K8scluster Receiver
contrib, k8s
Maintainers: @dmitryax, @TylerHelmuth, @povilasv, @ChrsMark
Source: opentelemetry-collector-contrib
Supported Telemetry
Overview
Metrics
Details about the metrics produced by this receiver can be found in metadata.yaml and documentation.md.Service Metrics (Disabled by default)
The receiver collects service endpoint metrics (k8s.service.endpoint.count) from the discovery.k8s.io EndpointSlice API and LoadBalancer ingress metrics (k8s.service.load_balancer.ingress.count).
Note: Enabling endpoint metrics requires additional RBAC permissions for endpointslices in the discovery.k8s.io API group. See the RBAC section for details.
Refer to documentation.md for detailed information on these metrics and their semantics.
Configuration
The following settings are required:auth_type(default =serviceAccount): Determines how to authenticate to the K8s API server. This can be one ofnone(for no auth),serviceAccount(to use the standard service account token provided to the agent pod), orkubeConfigto use credentials from~/.kube/config.
collection_interval(default =10s): This receiver continuously watches for events using K8s API. However, the metrics collected are emitted only once every collection interval.collection_intervalwill determine the frequency at which metrics are emitted by this receiver.metadata_collection_interval(default =5m): Collection interval for metadata for K8s entities such as pods, nodes, etc. Metadata of the particular entity in the cluster is collected when the entity changes. In addition, metadata of all entities is collected periodically even if no changes happen. This setting controls the interval between periodic collections. Setting the duration to 0 will disable periodic collection (however will not impact metadata collection on changes).node_conditions_to_report(default =[Ready]): An array of node conditions this receiver should report. The receiver will emit one metric per entry in the array.distribution(default =kubernetes): The Kubernetes distribution being used by the cluster. Currently supported versions arekubernetesandopenshift. Setting the value toopenshiftenables OpenShift specific metrics in addition to standard kubernetes ones.allocatable_types_to_report(default =[]): An array of allocatable resource types this receiver should report. The following allocatable resource types are available (see Node Allocatable in Kubernetes docs):- cpu
- memory
- ephemeral-storage
- pods
metrics: Allows to enable/disable metrics.resource_attributes: Allows to enable/disable resource attributes.namespace(deprecated, usenamespacesinstead): Allows to observe resources for a particular namespace only. If this option is set to a non-empty string,Nodes,NamespacesandClusterResourceQuotaswill not be observed.namespaces: Allows to observe resources for a list of given namespaces. If this option is set,Nodes,NamespacesandClusterResourceQuotaswill not be observed, as those are cluster-scoped resources.
k8s_leader_elector
Provide name of the k8s leader elector extension defined in config. This allows multiple instances of k8s cluster receiver to be executed on a cluster. At a given time only the pod which has the is active.node_conditions_to_report
For example, with the config below the receiver will emit two metricsk8s.node.condition_ready and k8s.node.condition_memory_pressure, one
for each condition in the config. The value will be 1 if the ConditionStatus for the
corresponding Condition is True, 0 if it is False and -1 if it is Unknown.
metadata_exporters
A list of metadata exporters to which metadata being collected by this receiver should be synced. Exporters specified in this list are expected to implement the following interface. If an exporter that does not implement the interface is listed, startup will fail.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.Example
Here is an example deployment of the collector that sets up this receiver along with the debug exporter. Follow the below sections to setup various Kubernetes resources required for the deployment.Configuration
Create a ConfigMap with the config forotelcontribcol:
Service Account
Create a service account that the collector should use.RBAC
Use the below commands to create aClusterRole with required permissions and a
ClusterRoleBinding to grant the role to the service account created above.
ClusterRole/ClusterRoleBinding, it is also possible to limit the observed resources to a list of
particular namespaces by setting the namespaces option of the receiver. This allows the collector to only rely on Roles/RoleBindings,
instead of granting the collector cluster-wide read access to resources.
Note however, that in this case the following cluster-scoped resources will not be observed by the k8sclusterreceiver:
NodesNamespacesPersistentVolumesClusterResourceQuotas
Role and RoleBinding for each of the namespaces the collector should observe:
Deployment
Create a Deployment to deploy the collector.OpenShift
You can enable OpenShift support to collect OpenShift specific metrics in addition to the default kubernetes ones. To do this, set thedistribution key to openshift.
Example:
Metrics
Attributes
Resource Attributes
Configuration
Example Configuration
Last generated: 2026-08-24