[k8s] Introduce semantic conventions for k8s CronJob labels and annotations (#2172)

Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
This commit is contained in:
odubajDT 2025-04-28 16:31:53 +02:00 committed by GitHub
parent 5eaa58617f
commit 7867bc07fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 60 additions and 6 deletions

View File

@ -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: enhancement
# 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: "Introduce semantic conventions for k8s CronJob labels and annotations"
# 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: [2138]
# (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:

View File

@ -17,6 +17,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` | ![Development](https://img.shields.io/badge/-development-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. | | ![Development](https://img.shields.io/badge/-development-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` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-cronjob-annotation" href="#k8s-cronjob-annotation">`k8s.cronjob.annotation.<key>`</a> | string | The annotation key-value pairs placed on the CronJob. [2] | `4`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-cronjob-label" href="#k8s-cronjob-label">`k8s.cronjob.label.<key>`</a> | string | The label key-value pairs placed on the CronJob. [3] | `weekly`; `` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-cronjob-name" href="#k8s-cronjob-name">`k8s.cronjob.name`</a> | string | The name of the CronJob. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-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` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-daemonset-name" href="#k8s-daemonset-name">`k8s.daemonset.name`</a> | string | The name of the DaemonSet. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-blue) |
@ -28,9 +30,9 @@ Kubernetes resource attributes.
| <a id="k8s-job-name" href="#k8s-job-name">`k8s.job.name`</a> | string | The name of the Job. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-job-uid" href="#k8s-job-uid">`k8s.job.uid`</a> | string | The UID of the Job. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-namespace-name" href="#k8s-namespace-name">`k8s.namespace.name`</a> | string | The name of the namespace that the pod is running in. | `default` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-namespace-phase" href="#k8s-namespace-phase">`k8s.namespace.phase`</a> | string | The phase of the K8s namespace. [2] | `active`; `terminating` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-annotation" href="#k8s-node-annotation">`k8s.node.annotation.<key>`</a> | string | The annotation key-value pairs placed on the Node. [3] | `k8s.node.annotation.node.alpha.kubernetes.io/ttl=0`; `k8s.node.annotation.data=` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-label" href="#k8s-node-label">`k8s.node.label.<key>`</a> | string | The label key-value pairs placed on the Node. [4] | `k8s.node.label.kubernetes.io/arch=arm64`; `k8s.node.label.data=` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-namespace-phase" href="#k8s-namespace-phase">`k8s.namespace.phase`</a> | string | The phase of the K8s namespace. [4] | `active`; `terminating` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-annotation" href="#k8s-node-annotation">`k8s.node.annotation.<key>`</a> | string | The annotation key-value pairs placed on the Node. [5] | `k8s.node.annotation.node.alpha.kubernetes.io/ttl=0`; `k8s.node.annotation.data=` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-label" href="#k8s-node-label">`k8s.node.label.<key>`</a> | string | The label key-value pairs placed on the Node. [6] | `k8s.node.label.kubernetes.io/arch=arm64`; `k8s.node.label.data=` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-name" href="#k8s-node-name">`k8s.node.name`</a> | string | The name of the Node. | `node-1` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-node-uid" href="#k8s-node-uid">`k8s.node.uid`</a> | string | The UID of the Node. | `1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2` | ![Development](https://img.shields.io/badge/-development-blue) |
| <a id="k8s-pod-annotation" href="#k8s-pod-annotation">`k8s.pod.annotation.<key>`</a> | string | The annotation key-value pairs placed on the Pod, the `<key>` being the annotation name, the value being the annotation value. | `k8s.pod.annotation.kubernetes.io/enforce-mountable-secrets=true`; `k8s.pod.annotation.mycompany.io/arch=x64`; `k8s.pod.annotation.data=` | ![Development](https://img.shields.io/badge/-development-blue) |
@ -71,12 +73,16 @@ Which states:
Therefore, UIDs between clusters should be extremely unlikely to
conflict.
**[2] `k8s.namespace.phase`:** This attribute aligns with the `phase` field of the
**[2] `k8s.cronjob.annotation`:** The `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
**[3] `k8s.cronjob.label`:** The `<key>` being the label name, the value being the label value, even if the value is empty.
**[4] `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)
**[3] `k8s.node.annotation`:** The `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
**[5] `k8s.node.annotation`:** The `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
**[4] `k8s.node.label`:** The `<key>` being the label name, the value being the label value, even if the value is empty.
**[6] `k8s.node.label`:** The `<key>` being the label name, the value being the label value, even if the value is empty.
---

View File

@ -353,6 +353,12 @@ A CronJob creates Jobs on a repeating schedule.
|---|---|---|---|---|---|
| [`k8s.cronjob.name`](/docs/attributes-registry/k8s.md) | string | The name of the CronJob. | `opentelemetry` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| [`k8s.cronjob.uid`](/docs/attributes-registry/k8s.md) | string | The UID of the CronJob. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
| [`k8s.cronjob.annotation.<key>`](/docs/attributes-registry/k8s.md) | string | The annotation key-value pairs placed on the CronJob. [1] | `4`; `` | `Opt-In` | ![Development](https://img.shields.io/badge/-development-blue) |
| [`k8s.cronjob.label.<key>`](/docs/attributes-registry/k8s.md) | string | The label key-value pairs placed on the CronJob. [2] | `weekly`; `` | `Opt-In` | ![Development](https://img.shields.io/badge/-development-blue) |
**[1] `k8s.cronjob.annotation`:** The `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
**[2] `k8s.cronjob.label`:** The `<key>` being the label name, the value being the label value, even if the value is empty.
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

View File

@ -229,6 +229,22 @@ groups:
brief: >
The name of the CronJob.
examples: ['opentelemetry']
- id: k8s.cronjob.label
type: template[string]
stability: development
brief: >
The label key-value pairs placed on the CronJob.
note: |
The `<key>` being the label name, the value being the label value, even if the value is empty.
examples: ['weekly', '']
- id: k8s.cronjob.annotation
type: template[string]
stability: development
brief: >
The annotation key-value pairs placed on the CronJob.
note: |
The `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
examples: [ '4', '' ]
- id: k8s.volume.name
type: string
stability: development

View File

@ -116,6 +116,10 @@ groups:
attributes:
- ref: k8s.cronjob.uid
- ref: k8s.cronjob.name
- ref: k8s.cronjob.label
requirement_level: opt_in
- ref: k8s.cronjob.annotation
requirement_level: opt_in
- id: resource.k8s.replicationcontroller
type: resource