Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add k8s.container.status.state metric #1784

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .chloggen/container-status.yaml
Original file line number Diff line number Diff line change
@@ -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:
29 changes: 29 additions & 0 deletions docs/attributes-registry/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Kubernetes resource attributes.
| <a id="k8s-container-name" href="#k8s-container-name">`k8s.container.name`</a> | 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) |
| <a id="k8s-container-restart-count" href="#k8s-container-restart-count">`k8s.container.restart_count`</a> | 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) |
| <a id="k8s-container-status-last-terminated-reason" href="#k8s-container-status-last-terminated-reason">`k8s.container.status.last_terminated_reason`</a> | string | Last terminated reason of the Container. | `Evicted`; `Error` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-container-status-reason" href="#k8s-container-status-reason">`k8s.container.status.reason`</a> | string | The reason for the container state. | `ContainerCreating`; `CrashLoopBackOff`; `CreateContainerConfigError`; `ErrImagePull`; `ImagePullBackOff`; `OOMKilled`; `Completed`; `Error`; `ContainerCannotRun` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-container-status-state" href="#k8s-container-status-state">`k8s.container.status.state`</a> | string | The state of the container. | `terminated`; `running`; `waiting` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-cronjob-name" href="#k8s-cronjob-name">`k8s.cronjob.name`</a> | string | The name of the CronJob. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-cronjob-uid" href="#k8s-cronjob-uid">`k8s.cronjob.uid`</a> | string | The UID of the CronJob. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-daemonset-name" href="#k8s-daemonset-name">`k8s.daemonset.name`</a> | string | The name of the DaemonSet. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
Expand Down Expand Up @@ -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 |
Expand Down
13 changes: 13 additions & 0 deletions model/k8s/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
ChrsMark marked this conversation as resolved.
Show resolved Hide resolved
- ref: k8s.container.status.state
requirement_level: required
- ref: k8s.container.status.reason

# k8s.node.* metrics
- id: metric.k8s.node.uptime
type: metric
Expand Down
66 changes: 66 additions & 0 deletions model/k8s/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,69 @@ groups:
value: 'terminating'
brief: "Terminating namespace phase as described by [K8s API](https://pkg.go.dev/k8s.io/[email protected]/core/v1#NamespacePhase)"
stability: experimental
- id: k8s.container.status.state
trask marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there corresponding K8s APIs that you can link to, similar to in k8s.namespace.phase above?

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any objection to snake case, just want to make sure we want to stick with this convention going forward for multi word attribute values?

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']
Loading