> ## Documentation Index
> Fetch the complete documentation index at: https://otel.fyi/llms.txt
> Use this file to discover all available pages before exploring further.

# K8scluster

> OpenTelemetry receiver for K8scluster

# K8scluster Receiver

![Status](https://img.shields.io/badge/status-beta-yellow)

**Available in:** `contrib`, `k8s`

**Maintainers:** [@dmitryax](https://github.com/dmitryax), [@TylerHelmuth](https://github.com/TylerHelmuth), [@povilasv](https://github.com/povilasv), [@ChrsMark](https://github.com/ChrsMark)

**Source:** [opentelemetry-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8sclusterreceiver)

## Supported Telemetry

![Logs](https://img.shields.io/badge/logs-development-blue) ![Metrics](https://img.shields.io/badge/metrics-beta-green)

## Overview

## Metrics

Details about the metrics produced by this receiver can be found in [metadata.yaml](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8sclusterreceiver/metadata.yaml) and [documentation.md](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8sclusterreceiver/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](#rbac) section for details.

Refer to [documentation.md](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8sclusterreceiver/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 of `none` (for no auth), `serviceAccount`
  (to use the standard service account token provided to the agent pod), or
  `kubeConfig` to use credentials from `~/.kube/config`.

The following settings are optional:

* `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_interval` will 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](https://kubernetes.io/docs/concepts/architecture/nodes/#condition)
  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 are `kubernetes` and `openshift`. Setting
  the value to `openshift` enables 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](https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable)):
  * cpu
  * memory
  * ephemeral-storage
  * pods

When enabled, this setting produces the following node-level metrics (one per selected type):

| 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, use `namespaces` instead): Allows to observe resources for a particular namespace only. If this option is set to a non-empty string, `Nodes`, `Namespaces` and `ClusterResourceQuotas` will not be observed.
* `namespaces`: Allows to observe resources for a list of given namespaces. If this option is set, `Nodes`, `Namespaces` and `ClusterResourceQuotas` will not be observed, as those are cluster-scoped resources.

Example:

```yaml theme={null}
  k8s_cluster:
    auth_type: kubeConfig
    k8s_leader_elector: <reference k8s leader elector extension>
    node_conditions_to_report: [Ready, MemoryPressure]
    allocatable_types_to_report: [cpu, memory]
    metrics:
      k8s.container.cpu_limit:
        enabled: false
    resource_attributes:
      container.id:
        enabled: false
```

The full list of settings exposed for this receiver are documented in [config.go](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8sclusterreceiver/config.go)
with detailed sample configurations in [testdata/config.yaml](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8sclusterreceiver/testdata/config.yaml).

### 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.

```yaml theme={null}
    k8s_cluster:
        k8s_leader_elector: k8s_leader_elector
...
```

### node\_conditions\_to\_report

For example, with the config below the receiver will emit two metrics
`k8s.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`.

```yaml theme={null}
...
k8s_cluster:
  node_conditions_to_report:
    - Ready
    - MemoryPressure
...
```

### 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.

```yaml theme={null}
type MetadataExporter interface {
  ConsumeMetadata(metadata []*MetadataUpdate) error
}

type MetadataUpdate struct {
  ResourceIDKey string
  ResourceID    ResourceID
  MetadataDelta
}

type MetadataDelta struct {
  MetadataToAdd    map[string]string
  MetadataToRemove map[string]string
  MetadataToUpdate map[string]string
}
```

See [experimentalmetricmetadata/metadata.go](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/experimentalmetricmetadata/metadata.go) for details about the above types.

The same metadata will be also emitted as entity events in the form of log records if
this receiver is connected to a logs pipeline.
See [opentelemetry-collector-contrib#23565](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/23565)
for the format of emitted log records.

## Compatibility

### Kubernetes Versions

This receiver is tested against the Kubernetes versions specified in the [e2e-tests.yml](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/.github/workflows/e2e-tests.yml#L97-L99)
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 for `otelcontribcol`:

```bash theme={null}
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
  name: otelcontribcol
  labels:
    app: otelcontribcol
data:
  config.yaml: |
    receivers:
      k8s_cluster:
        collection_interval: 10s
    exporters:
      debug:
    service:
      pipelines:
        metrics:
          receivers: [k8s_cluster]
          exporters: [debug]
        logs/entity_events:
          receivers: [k8s_cluster]
          exporters: [debug]
EOF
```

### Service Account

Create a service account that the collector should use.

```bash theme={null}
<<EOF | kubectl apply -f -
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app: otelcontribcol
  name: otelcontribcol
EOF
```

### RBAC

Use the below commands to create a `ClusterRole` with required permissions and a
`ClusterRoleBinding` to grant the role to the service account created above.

```bash theme={null}
<<EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: otelcontribcol
  labels:
    app: otelcontribcol
rules:
- apiGroups:
  - ""
  resources:
  - events
  - namespaces
  - namespaces/status
  - nodes
  - nodes/spec
  - persistentvolumes
  - persistentvolumeclaims
  - pods
  - pods/status
  - replicationcontrollers
  - replicationcontrollers/status
  - resourcequotas
  - services
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - discovery.k8s.io
  resources:
  - endpointslices
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - apps
  resources:
  - daemonsets
  - deployments
  - replicasets
  - statefulsets
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - extensions
  resources:
  - daemonsets
  - deployments
  - replicasets
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - batch
  resources:
  - jobs
  - cronjobs
  verbs:
  - get
  - list
  - watch
- apiGroups:
    - autoscaling
  resources:
    - horizontalpodautoscalers
  verbs:
    - get
    - list
    - watch
EOF
```

```bash theme={null}
<<EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: otelcontribcol
  labels:
    app: otelcontribcol
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: otelcontribcol
subjects:
- kind: ServiceAccount
  name: otelcontribcol
  namespace: default
EOF
```

As an alternative to setting up a `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`:

* `Nodes`
* `Namespaces`
* `PersistentVolumes`
* `ClusterResourceQuotas`

To use this approach, use the commands below to create the required `Role` and `RoleBinding` for each of the namespaces the collector should observe:

```bash theme={null}
<<EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: otelcontribcol
  labels:
    app: otelcontribcol
  namespace: default
rules:
  - apiGroups:
      - ""
    resources:
      - events
      - persistentvolumeclaims
      - pods
      - pods/status
      - replicationcontrollers
      - replicationcontrollers/status
      - resourcequotas
      - services
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - discovery.k8s.io
    resources:
      - endpointslices
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - apps
    resources:
      - daemonsets
      - deployments
      - replicasets
      - statefulsets
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - extensions
    resources:
      - daemonsets
      - deployments
      - replicasets
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - batch
    resources:
      - jobs
      - cronjobs
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - autoscaling
    resources:
      - horizontalpodautoscalers
    verbs:
      - get
      - list
      - watch
EOF
```

```bash theme={null}
<<EOF | kubectl apply -f -
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: otelcontribcol
  namespace: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: otelcontribcol
subjects:
  - kind: ServiceAccount
    name: otelcontribcol
    namespace: default
EOF
```

### Deployment

Create a [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) to deploy the collector.

```bash theme={null}
<<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: otelcontribcol
  labels:
    app: otelcontribcol
spec:
  replicas: 1
  selector:
    matchLabels:
      app: otelcontribcol
  template:
    metadata:
      labels:
        app: otelcontribcol
    spec:
      serviceAccountName: otelcontribcol
      containers:
      - name: otelcontribcol
        image: otel/opentelemetry-collector-contrib
        args: ["--config", "/etc/config/config.yaml"]
        volumeMounts:
        - name: config
          mountPath: /etc/config
        imagePullPolicy: IfNotPresent
      volumes:
        - name: config
          configMap:
            name: otelcontribcol
EOF
```

### OpenShift

You can enable OpenShift support to collect OpenShift specific metrics in addition to the default
kubernetes ones. To do this, set the `distribution` key to `openshift`.

Example:

```yaml theme={null}
  k8s_cluster:
    distribution: openshift
```

Add the following rules to your ClusterRole:

```yaml theme={null}
- apiGroups:
  - quota.openshift.io
  resources:
  - clusterresourcequotas
  verbs:
  - get
  - list
  - watch
```

## 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](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](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](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](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](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](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](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](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.persistentvolume.status.phase`          | The current phase of the PersistentVolume (1 for the current phase, 0 for others).                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | \{persistentvolume}      | UpDownCounter | k8s.persistentvolume.status.phase                                                             |
| ❌ `k8s.persistentvolume.storage.capacity`      | The storage capacity of the PersistentVolume.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | By                       | UpDownCounter |                                                                                               |
| ❌ `k8s.persistentvolumeclaim.status.phase`     | The current phase of the PersistentVolumeClaim (1 for the current phase, 0 for others).                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | \{persistentvolumeclaim} | UpDownCounter | k8s.persistentvolumeclaim.status.phase                                                        |
| ❌ `k8s.persistentvolumeclaim.storage.capacity` | The actual storage capacity provisioned for the PersistentVolumeClaim. Only available when bound.                                                                                                                                                                                                                                                                                                                                                                                                                                                           | By                       | UpDownCounter |                                                                                               |
| ❌ `k8s.persistentvolumeclaim.storage.request`  | The storage requested by the PersistentVolumeClaim.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | By                       | UpDownCounter |                                                                                               |
| ✅ `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](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.persistentvolume.status.phase`      | The phase of the PersistentVolume.                                                                                                                                                                                                                                     | string | `Pending`, `Available`, `Bound`, `Released`, `Failed`                                                                                                              |
| `k8s.persistentvolumeclaim.status.phase` | The phase of the PersistentVolumeClaim.                                                                                                                                                                                                                                | string | `Pending`, `Bound`, `Lost`                                                                                                                                         |
| `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.persistentvolume.name`                   | The name of the PersistentVolume.                                                | string | ✅       |
| `k8s.persistentvolume.reclaim_policy`         | The reclaim policy of the PersistentVolume.                                      | string | ❌       |
| `k8s.persistentvolume.uid`                    | The UID of the PersistentVolume.                                                 | string | ✅       |
| `k8s.persistentvolumeclaim.name`              | The name of the PersistentVolumeClaim.                                           | string | ✅       |
| `k8s.persistentvolumeclaim.uid`               | The UID of the PersistentVolumeClaim.                                            | 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 | ✅       |
| `k8s.storageclass.name`                       | The name of the StorageClass.                                                    | 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

```yaml theme={null}
k8s_cluster:
k8s_cluster/all_settings:
  collection_interval: 30s
  node_conditions_to_report: [ "Ready", "MemoryPressure" ]
  allocatable_types_to_report: [ "cpu","memory" ]
  metadata_exporters: [ nop ]
  metadata_collection_interval: 30m
k8s_cluster/partial_settings:
  collection_interval: 30s
  distribution: openshift
```

***

*Last generated: 2026-07-06*
