# K8s
- [Kubernetes Attributes](#kubernetes-attributes)
- [Deprecated Kubernetes Attributes](#deprecated-kubernetes-attributes)
## Kubernetes Attributes
Kubernetes resource attributes.
| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| `k8s.cluster.name` | string | The name of the cluster. | `opentelemetry-cluster` |  |
| `k8s.cluster.uid` | string | A pseudo-ID for the cluster, set to the UID of the `kube-system` namespace. [1] | `218fc5a9-a5f1-4b54-aa05-46717d0ab26d` |  |
| `k8s.container.name` | string | The name of the Container from Pod specification, must be unique within a Pod. Container runtime usually uses different globally unique name (`container.name`). | `redis` |  |
| `k8s.container.restart_count` | int | Number of times the container was restarted. This attribute can be used to identify a particular container (running or stopped) within a container spec. | |  |
| `k8s.container.status.last_terminated_reason` | string | Last terminated reason of the Container. | `Evicted`; `Error` |  |
| `k8s.container.status.reason` | string | The reason for the container state. Corresponds to the `reason` field of the: [K8s ContainerStateWaiting](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatewaiting-v1-core) or [K8s ContainerStateTerminated](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstateterminated-v1-core) | `ContainerCreating`; `CrashLoopBackOff`; `CreateContainerConfigError`; `ErrImagePull`; `ImagePullBackOff`; `OOMKilled`; `Completed`; `Error`; `ContainerCannotRun` |  |
| `k8s.container.status.state` | string | The state of the container. [K8s ContainerState](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstate-v1-core) | `terminated`; `running`; `waiting` |  |
| `k8s.cronjob.annotation.` | string | The cronjob annotation placed on the CronJob, the `` being the annotation name, the value being the annotation value. [2] | `4`; `` |  |
| `k8s.cronjob.label.` | string | The label placed on the CronJob, the `` being the label name, the value being the label value. [3] | `weekly`; `` |  |
| `k8s.cronjob.name` | string | The name of the CronJob. | `opentelemetry` |  |
| `k8s.cronjob.uid` | string | The UID of the CronJob. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.daemonset.annotation.` | string | The annotation key-value pairs placed on the DaemonSet. [4] | `k8s.daemonset.annotation.replicas=1`; `k8s.daemonset.annotation.data=` |  |
| `k8s.daemonset.label.` | string | The label key-value pairs placed on the DaemonSet. [5] | `k8s.daemonset.label.app=guestbook`; `k8s.daemonset.label.injected=` |  |
| `k8s.daemonset.name` | string | The name of the DaemonSet. | `opentelemetry` |  |
| `k8s.daemonset.uid` | string | The UID of the DaemonSet. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.deployment.annotation.` | string | The annotation key-value pairs placed on the Deployment. [6] | `k8s.deployment.annotation.replicas=1`; `k8s.deployment.annotation.data=` |  |
| `k8s.deployment.label.` | string | The label key-value pairs placed on the Deployment. [7] | `k8s.deployment.label.app=guestbook`; `k8s.deployment.label.injected=` |  |
| `k8s.deployment.name` | string | The name of the Deployment. | `opentelemetry` |  |
| `k8s.deployment.uid` | string | The UID of the Deployment. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.hpa.name` | string | The name of the horizontal pod autoscaler. | `opentelemetry` |  |
| `k8s.hpa.uid` | string | The UID of the horizontal pod autoscaler. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.job.annotation.` | string | The annotation key-value pairs placed on the Job. [8] | `k8s.job.annotation.number=1`; `k8s.job.annotation.data=` |  |
| `k8s.job.label.` | string | The label key-value pairs placed on the Job. [9] | `k8s.job.label.jobtype=ci`; `k8s.job.label.automated=` |  |
| `k8s.job.name` | string | The name of the Job. | `opentelemetry` |  |
| `k8s.job.uid` | string | The UID of the Job. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.namespace.annotation.` | string | The annotation key-value pairs placed on the Namespace. [10] | `k8s.namespace.annotation.ttl=0`; `k8s.namespace.annotation.data=` |  |
| `k8s.namespace.label.` | string | The label key-value pairs placed on the Namespace. [11] | `k8s.namespace.label.kubernetes.io/metadata.name=default`; `k8s.namespace.label.data=` |  |
| `k8s.namespace.name` | string | The name of the namespace that the pod is running in. | `default` |  |
| `k8s.namespace.phase` | string | The phase of the K8s namespace. [12] | `active`; `terminating` |  |
| `k8s.node.annotation.` | string | The annotation placed on the Node, the `` being the annotation name, the value being the annotation value, even if the value is empty. [13] | `0`; `` |  |
| `k8s.node.label.` | string | The label placed on the Node, the `` being the label name, the value being the label value, even if the value is empty. [14] | `arm64`; `` |  |
| `k8s.node.name` | string | The name of the Node. | `node-1` |  |
| `k8s.node.uid` | string | The UID of the Node. | `1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2` |  |
| `k8s.pod.annotation.` | string | The annotation placed on the Pod, the `` being the annotation name, the value being the annotation value. [15] | `true`; `x64`; `` |  |
| `k8s.pod.label.` | string | The label placed on the Pod, the `` being the label name, the value being the label value. [16] | `my-app`; `x64`; `` |  |
| `k8s.pod.name` | string | The name of the Pod. | `opentelemetry-pod-autoconf` |  |
| `k8s.pod.uid` | string | The UID of the Pod. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.replicaset.annotation.` | string | The annotation key-value pairs placed on the ReplicaSet. [17] | `k8s.replicaset.annotation.replicas=0`; `k8s.replicaset.annotation.data=` |  |
| `k8s.replicaset.label.` | string | The label key-value pairs placed on the ReplicaSet. [18] | `k8s.replicaset.label.app=guestbook`; `k8s.replicaset.label.injected=` |  |
| `k8s.replicaset.name` | string | The name of the ReplicaSet. | `opentelemetry` |  |
| `k8s.replicaset.uid` | string | The UID of the ReplicaSet. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.replicationcontroller.name` | string | The name of the replication controller. | `opentelemetry` |  |
| `k8s.replicationcontroller.uid` | string | The UID of the replication controller. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.resourcequota.name` | string | The name of the resource quota. | `opentelemetry` |  |
| `k8s.resourcequota.uid` | string | The UID of the resource quota. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.statefulset.annotation.` | string | The annotation key-value pairs placed on the StatefulSet. [19] | `k8s.statefulset.annotation.replicas=1`; `k8s.statefulset.annotation.data=` |  |
| `k8s.statefulset.label.` | string | The label key-value pairs placed on the StatefulSet. [20] | `k8s.statefulset.label.app=guestbook`; `k8s.statefulset.label.injected=` |  |
| `k8s.statefulset.name` | string | The name of the StatefulSet. | `opentelemetry` |  |
| `k8s.statefulset.uid` | string | The UID of the StatefulSet. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` |  |
| `k8s.volume.name` | string | The name of the K8s volume. | `volume0` |  |
| `k8s.volume.type` | string | The type of the K8s volume. | `emptyDir`; `persistentVolumeClaim` |  |
**[1] `k8s.cluster.uid`:** K8s doesn't have support for obtaining a cluster ID. If this is ever
added, we will recommend collecting the `k8s.cluster.uid` through the
official APIs. In the meantime, we are able to use the `uid` of the
`kube-system` namespace as a proxy for cluster ID. Read on for the
rationale.
Every object created in a K8s cluster is assigned a distinct UID. The
`kube-system` namespace is used by Kubernetes itself and will exist
for the lifetime of the cluster. Using the `uid` of the `kube-system`
namespace is a reasonable proxy for the K8s ClusterID as it will only
change if the cluster is rebuilt. Furthermore, Kubernetes UIDs are
UUIDs as standardized by
[ISO/IEC 9834-8 and ITU-T X.667](https://www.itu.int/ITU-T/studygroups/com17/oid.html).
Which states:
> If generated according to one of the mechanisms defined in Rec.
> ITU-T X.667 | ISO/IEC 9834-8, a UUID is either guaranteed to be
> different from all other UUIDs generated before 3603 A.D., or is
> extremely likely to be different (depending on the mechanism chosen).
Therefore, UIDs between clusters should be extremely unlikely to
conflict.
**[2] `k8s.cronjob.annotation.`:** Examples:
- An annotation `retries` with value `4` SHOULD be recorded as the
`k8s.cronjob.annotation.retries` attribute with value `"4"`.
- An annotation `data` with empty string value SHOULD be recorded as
the `k8s.cronjob.annotation.data` attribute with value `""`.
**[3] `k8s.cronjob.label.`:** Examples:
- A label `type` with value `weekly` SHOULD be recorded as the
`k8s.cronjob.label.type` attribute with value `"weekly"`.
- A label `automated` with empty string value SHOULD be recorded as
the `k8s.cronjob.label.automated` attribute with value `""`.
**[4] `k8s.daemonset.annotation.`:** The `` being the annotation name, the value being the annotation value, even if the value is empty.
**[5] `k8s.daemonset.label.`:** The `` being the label name, the value being the label value, even if the value is empty.
**[6] `k8s.deployment.annotation.`:** The `` being the annotation name, the value being the annotation value, even if the value is empty.
**[7] `k8s.deployment.label.`:** The `` being the label name, the value being the label value, even if the value is empty.
**[8] `k8s.job.annotation.`:** The `` being the annotation name, the value being the annotation value, even if the value is empty.
**[9] `k8s.job.label.`:** The `` being the label name, the value being the label value, even if the value is empty.
**[10] `k8s.namespace.annotation.`:** The `` being the annotation name, the value being the annotation value, even if the value is empty.
**[11] `k8s.namespace.label.`:** The `` being the label name, the value being the label value, even if the value is empty.
**[12] `k8s.namespace.phase`:** This attribute aligns with the `phase` field of the
[K8s NamespaceStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#namespacestatus-v1-core)
**[13] `k8s.node.annotation.`:** Examples:
- An annotation `node.alpha.kubernetes.io/ttl` with value `0` SHOULD be recorded as
the `k8s.node.annotation.node.alpha.kubernetes.io/ttl` attribute with value `"0"`.
- An annotation `data` with empty string value SHOULD be recorded as
the `k8s.node.annotation.data` attribute with value `""`.
**[14] `k8s.node.label.`:** Examples:
- A label `kubernetes.io/arch` with value `arm64` SHOULD be recorded
as the `k8s.node.label.kubernetes.io/arch` attribute with value `"arm64"`.
- A label `data` with empty string value SHOULD be recorded as
the `k8s.node.label.data` attribute with value `""`.
**[15] `k8s.pod.annotation.`:** Examples:
- An annotation `kubernetes.io/enforce-mountable-secrets` with value `true` SHOULD be recorded as
the `k8s.pod.annotation.kubernetes.io/enforce-mountable-secrets` attribute with value `"true"`.
- An annotation `mycompany.io/arch` with value `x64` SHOULD be recorded as
the `k8s.pod.annotation.mycompany.io/arch` attribute with value `"x64"`.
- An annotation `data` with empty string value SHOULD be recorded as
the `k8s.pod.annotation.data` attribute with value `""`.
**[16] `k8s.pod.label.`:** Examples:
- A label `app` with value `my-app` SHOULD be recorded as
the `k8s.pod.label.app` attribute with value `"my-app"`.
- A label `mycompany.io/arch` with value `x64` SHOULD be recorded as
the `k8s.pod.label.mycompany.io/arch` attribute with value `"x64"`.
- A label `data` with empty string value SHOULD be recorded as
the `k8s.pod.label.data` attribute with value `""`.
**[17] `k8s.replicaset.annotation.`:** The `` being the annotation name, the value being the annotation value, even if the value is empty.
**[18] `k8s.replicaset.label.`:** The `` being the label name, the value being the label value, even if the value is empty.
**[19] `k8s.statefulset.annotation.`:** The `` being the annotation name, the value being the annotation value, even if the value is empty.
**[20] `k8s.statefulset.label.`:** The `` being the label name, the value being the label value, even if the value is empty.
---
`k8s.container.status.reason` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `Completed` | The container has completed execution. |  |
| `ContainerCannotRun` | The container cannot run. |  |
| `ContainerCreating` | The container is being created. |  |
| `CrashLoopBackOff` | The container is in a crash loop back off state. |  |
| `CreateContainerConfigError` | There was an error creating the container configuration. |  |
| `ErrImagePull` | There was an error pulling the container image. |  |
| `Error` | There was an error with the container. |  |
| `ImagePullBackOff` | The container image pull is in back off state. |  |
| `OOMKilled` | The container was killed due to out of memory. |  |
---
`k8s.container.status.state` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `running` | The container is running. |  |
| `terminated` | The container has terminated. |  |
| `waiting` | The container is waiting. |  |
---
`k8s.namespace.phase` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `active` | Active namespace phase as described by [K8s API](https://pkg.go.dev/k8s.io/api@v0.31.3/core/v1#NamespacePhase) |  |
| `terminating` | Terminating namespace phase as described by [K8s API](https://pkg.go.dev/k8s.io/api@v0.31.3/core/v1#NamespacePhase) |  |
---
`k8s.volume.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.
| Value | Description | Stability |
|---|---|---|
| `configMap` | A [configMap](https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#configmap) volume |  |
| `downwardAPI` | A [downwardAPI](https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#downwardapi) volume |  |
| `emptyDir` | An [emptyDir](https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#emptydir) volume |  |
| `local` | A [local](https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#local) volume |  |
| `persistentVolumeClaim` | A [persistentVolumeClaim](https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim) volume |  |
| `secret` | A [secret](https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#secret) volume |  |
## Deprecated Kubernetes Attributes
Describes deprecated k8s attributes.
| Attribute | Type | Description | Examples | Stability |
|---|---|---|---|---|
| `k8s.pod.labels.` | string | Deprecated, use `k8s.pod.label` instead. | `my-app` | 
Replaced by `k8s.pod.label`. |