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
| allocatable type | metric name | unit | type | value type |
|---|---|---|---|---|
| cpu | k8s.node.allocatable_cpu | {cpu} | Gauge | Double |
| memory | k8s.node.allocatable_memory | By | Gauge | Double |
| ephemeral-storage | k8s.node.allocatable_ephemeral_storage | By | Gauge | Double |
| pods | k8s.node.allocatable_pods | {pod} | Gauge | Int |
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 resources will not be observed by the k8sclusterreceiver:
NodesNamespacesClusterResourceQuotas
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
| Metric Name | Description | Unit | Type | Attributes |
|---|---|---|---|---|
✅ k8s.container.cpu_limit | Maximum resource limit set for the container. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#resourcerequirements-v1-core for details | {cpu} | Gauge | |
✅ k8s.container.cpu_request | Resource requested for the container. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#resourcerequirements-v1-core for details | {cpu} | Gauge | |
✅ k8s.container.ephemeralstorage_limit | Maximum resource limit set for the container. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#resourcerequirements-v1-core for details | By | Gauge | |
✅ k8s.container.ephemeralstorage_request | Resource requested for the container. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#resourcerequirements-v1-core for details | By | Gauge | |
✅ k8s.container.memory_limit | Maximum resource limit set for the container. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#resourcerequirements-v1-core for details | By | Gauge | |
✅ k8s.container.memory_request | Resource requested for the container. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#resourcerequirements-v1-core for details | By | Gauge | |
✅ k8s.container.ready | Whether a container has passed its readiness probe (0 for no, 1 for yes) | Gauge | ||
✅ k8s.container.restarts | How many times the container has restarted in the recent past. This value is pulled directly from the K8s API and the value can go indefinitely high and be reset to 0 at any time depending on how your kubelet is configured to prune dead containers. It is best to not depend too much on the exact value but rather look at it as either == 0, in which case you can conclude there were no restarts in the recent past, or > 0, in which case you can conclude there were restarts in the recent past, and not try and analyze the value beyond that. | {restart} | Gauge | |
❌ k8s.container.status.reason | Experimental metric, may experience breaking changes. Describes the number of K8s containers that are currently in a state for a given reason. All possible container state reasons will be reported at each time interval to avoid missing metrics. Only the value corresponding to the current state reason will be non-zero. | {container} | UpDownCounter | k8s.container.status.reason |
❌ k8s.container.status.state | Experimental metric, may experience breaking changes. Describes the number of K8s containers that are currently in a given state. All possible container states will be reported at each time interval to avoid missing metrics. Only the value corresponding to the current state will be non-zero. | {container} | UpDownCounter | k8s.container.status.state |
✅ k8s.container.storage_limit | Maximum resource limit set for the container. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#resourcerequirements-v1-core for details | By | Gauge | |
✅ k8s.container.storage_request | Resource requested for the container. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/#resourcerequirements-v1-core for details | By | Gauge | |
✅ k8s.cronjob.active_jobs | The number of actively running jobs for a cronjob | {job} | Gauge | |
✅ k8s.daemonset.current_scheduled_nodes | Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod | {node} | Gauge | |
✅ k8s.daemonset.desired_scheduled_nodes | Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod) | {node} | Gauge | |
✅ k8s.daemonset.misscheduled_nodes | Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod | {node} | Gauge | |
✅ k8s.daemonset.ready_nodes | Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready | {node} | Gauge | |
✅ k8s.deployment.available | Total number of available pods (ready for at least minReadySeconds) targeted by this deployment | {pod} | Gauge | |
✅ k8s.deployment.desired | Number of desired pods in this deployment | {pod} | Gauge | |
✅ k8s.hpa.current_replicas | Current number of pod replicas managed by this autoscaler. | {pod} | Gauge | |
✅ k8s.hpa.desired_replicas | Desired number of pod replicas managed by this autoscaler. | {pod} | Gauge | |
✅ k8s.hpa.max_replicas | Maximum number of replicas to which the autoscaler can scale up. | {pod} | Gauge | |
✅ k8s.hpa.min_replicas | Minimum number of replicas to which the autoscaler can scale up. | {pod} | Gauge | |
✅ k8s.job.active_pods | The number of actively running pods for a job | {pod} | Gauge | |
✅ k8s.job.desired_successful_pods | The desired number of successfully finished pods the job should be run with | {pod} | Gauge | |
✅ k8s.job.failed_pods | The number of pods which reached phase Failed for a job | {pod} | Gauge | |
✅ k8s.job.max_parallel_pods | The max desired number of pods the job should run at any given time | {pod} | Gauge | |
✅ k8s.job.successful_pods | The number of pods which reached phase Succeeded for a job | {pod} | Gauge | |
✅ k8s.namespace.phase | The current phase of namespaces (1 for active and 0 for terminating) | Gauge | ||
❌ k8s.node.condition | The condition of a particular Node. | {condition} | Gauge | condition |
✅ k8s.pod.phase | Current phase of the pod (1 - Pending, 2 - Running, 3 - Succeeded, 4 - Failed, 5 - Unknown) | Gauge | ||
❌ k8s.pod.status_reason | Current status reason of the pod (1 - Evicted, 2 - NodeAffinity, 3 - NodeLost, 4 - Shutdown, 5 - UnexpectedAdmissionError, 6 - Unknown) | Gauge | ||
✅ k8s.replicaset.available | Total number of available pods (ready for at least minReadySeconds) targeted by this replicaset | {pod} | Gauge | |
✅ k8s.replicaset.desired | Number of desired pods in this replicaset | {pod} | Gauge | |
✅ k8s.replication_controller.available | Total number of available pods (ready for at least minReadySeconds) targeted by this replication_controller | {pod} | Gauge | |
✅ k8s.replication_controller.desired | Number of desired pods in this replication_controller | {pod} | Gauge | |
✅ k8s.resource_quota.hard_limit | The upper limit for a particular resource in a specific namespace. Will only be sent if a quota is specified. CPU requests/limits will be sent as millicores | {resource} | Gauge | resource |
✅ k8s.resource_quota.used | The usage for a particular resource in a specific namespace. Will only be sent if a quota is specified. CPU requests/limits will be sent as millicores | {resource} | Gauge | resource |
❌ k8s.service.endpoint.count | The number of endpoints for a service, broken down by condition, address type, and zone. | {endpoint} | Gauge | k8s.service.endpoint.address_type, k8s.service.endpoint.condition, k8s.service.endpoint.zone |
❌ k8s.service.load_balancer.ingress.count | The number of load balancer ingress points (external IPs/hostnames) assigned to the service. | {ingress} | Gauge | |
✅ k8s.statefulset.current_pods | The number of pods created by the StatefulSet controller from the StatefulSet version | {pod} | Gauge | |
✅ k8s.statefulset.desired_pods | Number of desired pods in the stateful set (the spec.replicas field) | {pod} | Gauge | |
✅ k8s.statefulset.ready_pods | Number of pods created by the stateful set that have the Ready condition | {pod} | Gauge | |
✅ k8s.statefulset.updated_pods | Number of pods created by the StatefulSet controller from the StatefulSet version | {pod} | Gauge | |
✅ openshift.appliedclusterquota.limit | The upper limit for a particular resource in a specific namespace. | {resource} | Gauge | k8s.namespace.name, resource |
✅ openshift.appliedclusterquota.used | The usage for a particular resource in a specific namespace. | {resource} | Gauge | k8s.namespace.name, resource |
✅ openshift.clusterquota.limit | The configured upper limit for a particular resource. | {resource} | Gauge | resource |
✅ openshift.clusterquota.used | The usage for a particular resource with a configured limit. | {resource} | Gauge | resource |
Attributes
| Attribute Name | Description | Type | Values |
|---|---|---|---|
condition | the name of Kubernetes Node condition. Example: Ready, Memory, PID, DiskPressure | string | |
k8s.container.status.reason | The reason of the current container status. | string | ContainerCreating, CrashLoopBackOff, CreateContainerConfigError, ErrImagePull, ImagePullBackOff, OOMKilled, Completed, Error, ContainerCannotRun |
k8s.container.status.state | The state of the container (terminated, running, waiting). See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstate-v1-core for details. | string | terminated, running, waiting |
k8s.namespace.name | The k8s namespace name. | string | |
k8s.service.endpoint.address_type | The address type of the endpoint. | string | IPv4, IPv6, FQDN |
k8s.service.endpoint.condition | The condition of the service endpoint. | string | ready, serving, terminating |
k8s.service.endpoint.zone | The zone of the service endpoint, typically corresponding to a failure domain. | string | |
resource | the name of the resource on which the quota is applied | string |
Resource Attributes
| Attribute Name | Description | Type | Enabled |
|---|---|---|---|
container.id | The container id. | string | ✅ |
container.image.name | The container image name | string | ✅ |
container.image.tag | The container image tag | string | ✅ |
container.runtime | The container runtime used by Kubernetes Node. | string | ❌ |
container.runtime.version | The version of container runtime used by Kubernetes Node. | string | ❌ |
k8s.container.name | The k8s container name | string | ✅ |
k8s.container.status.last_terminated_reason | Last terminated reason of a container. | string | ❌ |
k8s.cronjob.name | The k8s CronJob name | string | ✅ |
k8s.cronjob.uid | The k8s CronJob uid. | string | ✅ |
k8s.daemonset.name | The k8s daemonset name. | string | ✅ |
k8s.daemonset.uid | The k8s daemonset uid. | string | ✅ |
k8s.deployment.name | The name of the Deployment. | string | ✅ |
k8s.deployment.uid | The UID of the Deployment. | string | ✅ |
k8s.hpa.name | The k8s hpa name. | string | ✅ |
k8s.hpa.scaletargetref.apiversion | The API version of the target resource to scale for the HorizontalPodAutoscaler. | string | ❌ |
k8s.hpa.scaletargetref.kind | The kind of the target resource to scale for the HorizontalPodAutoscaler. | string | ❌ |
k8s.hpa.scaletargetref.name | The name of the target resource to scale for the HorizontalPodAutoscaler. | string | ❌ |
k8s.hpa.uid | The k8s hpa uid. | string | ✅ |
k8s.job.name | The k8s pod name. | string | ✅ |
k8s.job.uid | The k8s job uid. | string | ✅ |
k8s.kubelet.version | The version of Kubelet running on the node. | string | ❌ |
k8s.namespace.name | The k8s namespace name. | string | ✅ |
k8s.namespace.uid | The k8s namespace uid. | string | ✅ |
k8s.node.name | The k8s node name. | string | ✅ |
k8s.node.uid | The k8s node uid. | string | ✅ |
k8s.pod.name | The k8s pod name. | string | ✅ |
k8s.pod.qos_class | The k8s pod qos class name. One of Guaranteed, Burstable, BestEffort. | string | ❌ |
k8s.pod.uid | The k8s pod uid. | string | ✅ |
k8s.replicaset.name | The k8s replicaset name | string | ✅ |
k8s.replicaset.uid | The k8s replicaset uid | string | ✅ |
k8s.replicationcontroller.name | The k8s replicationcontroller name. | string | ✅ |
k8s.replicationcontroller.uid | The k8s replicationcontroller uid. | string | ✅ |
k8s.resourcequota.name | The k8s resourcequota name. | string | ✅ |
k8s.resourcequota.uid | The k8s resourcequota uid. | string | ✅ |
k8s.service.name | The k8s service name. | string | ✅ |
k8s.service.publish_not_ready_addresses | Whether the Service publishes not-ready endpoints. | bool | ❌ |
k8s.service.traffic_distribution | The traffic distribution policy for the Service (e.g., PreferClose). | string | ❌ |
k8s.service.type | The k8s service type. | string | ✅ |
k8s.service.uid | The k8s service uid. | string | ✅ |
k8s.statefulset.name | The k8s statefulset name. | string | ✅ |
k8s.statefulset.uid | The k8s statefulset uid. | string | ✅ |
openshift.clusterquota.name | The k8s ClusterResourceQuota name. | string | ✅ |
openshift.clusterquota.uid | The k8s ClusterResourceQuota uid. | string | ✅ |
os.description | The os description used by Kubernetes Node. | string | ❌ |
os.type | The os type used by Kubernetes Node. | string | ❌ |
Configuration
Example Configuration
Last generated: 2026-04-13