K8sobjects Receiver
contrib, k8s
Maintainers: @dmitryax, @hvaghani221, @TylerHelmuth, @ChrsMark, @krisztianfekete
Source: opentelemetry-collector-contrib
Supported Telemetry
Overview
Currently this receiver supports authentication via service accounts only. See example for more information.Getting Started
The following is example configurationauth_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.error_mode(default =propagate): Determines how to handle errors when the receiver is unable to pull or watch objects due to missing resources. This can be one ofpropagate,ignore, orsilent.propagatewill propagate the error to the collector as an Error.ignorewill log and ignore the error and continue.silentwill ignore the error and continue without logging.
interval: Top level pull interval applied to all pull-mode objects that do not set their owninterval. Falls back to1hwhen neither this field nor the per-resourceobjects[*].intervalis set. Has no effect on watch-mode objects.name: Name of the resource object to collectmode: define in which way it collects this type of object, either “pull” or “watch”.pullmode will read all objects of this type use the list API at an interval.watchmode will do setup a long connection using the watch API to just get updates.
include_initial_state(default =false): When set totrue(watch-mode only) the receiver sends a one-time snapshot of the current objects before it starts processing watch events.label_selector: select objects by label(s)field_selector: select objects by field(s)objects[*].interval: per-resource pull interval override. When set, takes precedence over the top-levelinterval. Only applies topullmode objects.exclude_watch_type: allows excluding specific watch types. Valid values areADDED,MODIFIED,DELETED,BOOKMARK, andERROR. Only usable inwatchmode.resource_version: allows watching resources starting from a specific version (default =1). Only available forwatchmode. If not specified, the receiver will do an initial list to get the resourceVersion before starting the watch. See Efficient Detection of Change for details on why this is necessary.namespaces: An array ofnamespacesto collect events from. (default =all)exclude_namespaces: allows excluding namespaces from being watched/pulled, (NOTE: if a new namespace that matches the regex is added, the collector will need to be restarted)group: API group name. It is an optional config. When given resource object is present in multiple groups, use this config to specify the group to select. By default, it will select the first group. For example,eventsresource is available in bothv1andevents.k8s.io/v1APIGroup. In this case, it will selectv1by default.kube_api_qps(default =5): Maximum number of queries per second to the Kubernetes API. Increase this if you seeclient-side throttlingwarnings in the collector logs when watching or polling many resources simultaneously.kube_api_burst(default =10): Maximum burst size for requests to the Kubernetes API. Increase this alongsidekube_api_qpsif you seeclient-side throttlingwarnings.k8s_leader_elector(default: none): if specified, will enable Leader Election by usingk8sleaderelectorextensionstorage(default: none): specifies the storage extension to use for persisting resourceVersions. When configured, the receiver automatically persists the resourceVersion after processing each event for all watch-mode objects. On restart, each watch-mode object resumes from its persisted resourceVersion, preventing duplicate events. Pull-mode objects are unaffected.Important storage considerations:
- Local or node-pinned volumes (
hostPath, local PV): the collector pod becomes tied to a specific node. If that node fails or the pod is rescheduled elsewhere, the persisted data will not be accessible and persistence will not work correctly. - Network-attached volumes (
ReadWriteMany): the volume is accessible from any node, so the collector pod can be freely rescheduled or fail over to a different node while still resuming from the correct resourceVersion. This is the recommended approach, especially when used withk8s_leader_elector. - Block volumes (
ReadWriteOnce): supported for single-replica deployments where restarts are graceful. Not recommended with leader election across multiple nodes, as Kubernetes may take 30–90 seconds to detach and reattach the volume after a node failure.
- Local or node-pinned volumes (
Supported Kubernetes objects
Thek8sobjectsreceiver supports collecting a wide range of standard Kubernetes objects from the API server. For example, the mostly used supported objects
(in addition to other standard Kubernetes objects) are:
podseventsnodesjobscronjobsdeploymentsservicesconfigmapssecretsstatefulsetsreplicasetsdaemonsetsnamespaces
pull and watch modes, allowing for flexible and real-time monitoring of these objects. Please note that custom resources are supported only if their CRDs are available in the cluster.
Configuration
Create a ConfigMap with the config forotelcontribcol. Replace OTLP_ENDPOINT
with valid value.
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.
Following config will work for collecting pods and events only. You need to add
appropriate rule for collecting other objects.
When using watch mode you must also specify list verb so that the receiver has permission to do its initial list if no
resource_version was supplied or a list to recover from 410 Gone scenarios.
Deployment
Create a Deployment to deploy the collector. Note: This receiver must be deployed as one replica, otherwise it’ll be producing duplicated data.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.Troubleshooting
If receiver returns error similar to below, make sure that resource is added toClusterRole.
Configuration
Example Configuration
Last generated: 2026-06-01