diff --git a/.chloggen/container-status.yaml b/.chloggen/container-status.yaml new file mode 100755 index 0000000000..09007b2d87 --- /dev/null +++ b/.chloggen/container-status.yaml @@ -0,0 +1,22 @@ +# Use this changelog template to create an entry for release notes. +# +# If your change doesn't affect end users you should instead start +# your pull request title with [chore] or use the "Skip Changelog" label. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: new_component + +# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db) +component: k8s + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Add k8s.container.status.state metric" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +# The values here must be integers. +issues: [1672] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/docs/attributes-registry/k8s.md b/docs/attributes-registry/k8s.md index ab3c706dc8..8400c8a390 100644 --- a/docs/attributes-registry/k8s.md +++ b/docs/attributes-registry/k8s.md @@ -20,6 +20,8 @@ Kubernetes resource attributes. | `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` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | `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. | | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | `k8s.container.status.last_terminated_reason` | string | Last terminated reason of the Container. | `Evicted`; `Error` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `k8s.container.status.reason` | string | The reason for the container state. | `ContainerCreating`; `CrashLoopBackOff`; `CreateContainerConfigError`; `ErrImagePull`; `ImagePullBackOff`; `OOMKilled`; `Completed`; `Error`; `ContainerCannotRun` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `k8s.container.status.state` | string | The state of the container. | `terminated`; `running`; `waiting` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | `k8s.cronjob.name` | string | The name of the CronJob. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | `k8s.cronjob.uid` | string | The UID of the CronJob. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | | `k8s.daemonset.name` | string | The name of the DaemonSet. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) | @@ -71,6 +73,33 @@ conflict. --- +`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 | +|---|---|---| +| `` | Reason unknown. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `Completed` | The container has completed execution. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `ContainerCannotRun` | The container cannot run. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `ContainerCreating` | The container is being created. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `CrashLoopBackOff` | The container is in a crash loop back off state. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `CreateContainerConfigError` | There was an error creating the container configuration. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `ErrImagePull` | There was an error pulling the container image. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `Error` | There was an error with the container. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `ImagePullBackOff` | The container image pull is in back off state. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `OOMKilled` | The container was killed due to out of memory. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | + +--- + +`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. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `terminated` | The container has terminated. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | +| `waiting` | The container is waiting. | ![Experimental](https://img.shields.io/badge/-experimental-blue) | + +--- + `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 | diff --git a/model/k8s/metrics.yaml b/model/k8s/metrics.yaml index c091a5e4a0..fb00f17e56 100644 --- a/model/k8s/metrics.yaml +++ b/model/k8s/metrics.yaml @@ -63,6 +63,19 @@ groups: - ref: network.interface.name - ref: network.io.direction + # k8s.container.* metrics + - id: metric.k8s.container.status.state + type: metric + metric_name: k8s.container.status.state + stability: experimental + brief: "" + instrument: updowncounter + unit: "" + attributes: + - ref: k8s.container.status.state + requirement_level: required + - ref: k8s.container.status.reason + # k8s.node.* metrics - id: metric.k8s.node.uptime type: metric diff --git a/model/k8s/registry.yaml b/model/k8s/registry.yaml index c9b639b697..f23442eca7 100644 --- a/model/k8s/registry.yaml +++ b/model/k8s/registry.yaml @@ -232,3 +232,69 @@ groups: value: 'terminating' brief: "Terminating namespace phase as described by [K8s API](https://pkg.go.dev/k8s.io/api@v0.31.3/core/v1#NamespacePhase)" stability: experimental + - id: k8s.container.status.state + stability: experimental + brief: > + The state of the container. + type: + members: + - id: terminated + value: 'terminated' + brief: 'The container has terminated.' + stability: experimental + - id: running + value: 'running' + brief: 'The container is running.' + stability: experimental + - id: waiting + value: 'waiting' + brief: 'The container is waiting.' + stability: experimental + examples: ['terminated', 'running', 'waiting'] + - id: k8s.container.status.reason + type: + members: + - id: container_creating + value: 'ContainerCreating' + brief: 'The container is being created.' + stability: experimental + - id: crash_loop_back_off + value: 'CrashLoopBackOff' + brief: 'The container is in a crash loop back off state.' + stability: experimental + - id: create_container_config_error + value: 'CreateContainerConfigError' + brief: 'There was an error creating the container configuration.' + stability: experimental + - id: err_image_pull + value: 'ErrImagePull' + brief: 'There was an error pulling the container image.' + stability: experimental + - id: image_pull_back_off + value: 'ImagePullBackOff' + brief: 'The container image pull is in back off state.' + stability: experimental + - id: oom_killed + value: 'OOMKilled' + brief: 'The container was killed due to out of memory.' + stability: experimental + - id: completed + value: 'Completed' + brief: 'The container has completed execution.' + stability: experimental + - id: error + value: 'Error' + brief: 'There was an error with the container.' + stability: experimental + - id: container_cannot_run + value: 'ContainerCannotRun' + brief: 'The container cannot run.' + stability: experimental + - id: empty + value: '' + brief: 'Reason unknown.' + stability: experimental + stability: experimental + brief: > + The reason for the container state. + examples: ['ContainerCreating', 'CrashLoopBackOff', 'CreateContainerConfigError', 'ErrImagePull', 'ImagePullBackOff', 'OOMKilled', 'Completed', 'Error', 'ContainerCannotRun']