Skip to content

Commit

Permalink
Add hpa, resource_quota, replication_controller k8s attributes
Browse files Browse the repository at this point in the history
Signed-off-by: ChrsMark <[email protected]>
  • Loading branch information
ChrsMark committed Jan 22, 2025
1 parent 2eb5802 commit ec47412
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .chloggen/add_k8s_resources.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: 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: Add hpa, resource_quota and replication_controller resource attributes

# 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: [1656]

# (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:
6 changes: 6 additions & 0 deletions docs/attributes-registry/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Kubernetes resource attributes.
| <a id="k8s-daemonset-uid" href="#k8s-daemonset-uid">`k8s.daemonset.uid`</a> | string | The UID of the DaemonSet. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-deployment-name" href="#k8s-deployment-name">`k8s.deployment.name`</a> | string | The name of the Deployment. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-deployment-uid" href="#k8s-deployment-uid">`k8s.deployment.uid`</a> | string | The UID of the Deployment. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-hpa-name" href="#k8s-hpa-name">`k8s.hpa.name`</a> | string | The name of the horizontal pod autoscaler. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-hpa-uid" href="#k8s-hpa-uid">`k8s.hpa.uid`</a> | string | The UID of the horizontal pod autoscaler. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-job-name" href="#k8s-job-name">`k8s.job.name`</a> | string | The name of the Job. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-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` | ![Experimental](https://img.shields.io/badge/-experimental-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` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
Expand All @@ -38,6 +40,10 @@ Kubernetes resource attributes.
| <a id="k8s-pod-uid" href="#k8s-pod-uid">`k8s.pod.uid`</a> | string | The UID of the Pod. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-replicaset-name" href="#k8s-replicaset-name">`k8s.replicaset.name`</a> | string | The name of the ReplicaSet. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-replicaset-uid" href="#k8s-replicaset-uid">`k8s.replicaset.uid`</a> | string | The UID of the ReplicaSet. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-replication-controller-name" href="#k8s-replication-controller-name">`k8s.replication_controller.name`</a> | string | The name of the replication controller. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-replication-controller-uid" href="#k8s-replication-controller-uid">`k8s.replication_controller.uid`</a> | string | The UID of the replication controller. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-resource-quota-name" href="#k8s-resource-quota-name">`k8s.resource_quota.name`</a> | string | The name of the resource quota. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-resource-quota-uid" href="#k8s-resource-quota-uid">`k8s.resource_quota.uid`</a> | string | The UID of the resource quota. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-statefulset-name" href="#k8s-statefulset-name">`k8s.statefulset.name`</a> | string | The name of the StatefulSet. | `opentelemetry` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-statefulset-uid" href="#k8s-statefulset-uid">`k8s.statefulset.uid`</a> | string | The UID of the StatefulSet. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| <a id="k8s-volume-name" href="#k8s-volume-name">`k8s.volume.name`</a> | string | The name of the K8s volume. | `volume0` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
Expand Down
40 changes: 40 additions & 0 deletions docs/non-normative/k8s-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ and one for disabling the old schema called `semconv.k8s.disableLegacy`. Then:
- [K8s Job metrics](#k8s-job-metrics)
- [K8s Cronjob metrics](#k8s-cronjob-metrics)
- [K8s Namespace metrics](#k8s-namespace-metrics)
- [K8s ReplicationController attributes](#k8s-replicationcontroller-attributes)
- [K8s ResourceQuota attributes](#k8s-resourcequota-attributes)

<!-- tocstop -->

Expand Down Expand Up @@ -253,3 +255,41 @@ The changes in their metrics are the following:
| `k8s.namespace.phase` (type: `gauge`), 1 for active and 0 for terminating | `k8s.namespace.phase` (type: `updowncounter`), with the attribute `k8s.namespace.phase` indicating the phase |

<!-- prettier-ignore-end -->

### K8s ReplicationController attributes

The K8s ReplicationController attributes implemented by the Collector and specifically the
[k8scluster](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.115.0/receiver/k8sclusterreceiver/documentation.md)
receiver were introduced as semantic conventions in
[#1649](https://github.com/open-telemetry/semantic-conventions/pull/1742) (TODO: replace with SemConv version once
available).

The changes are the following:

<!-- prettier-ignore-start -->

| Old (Collector) ![changed](https://img.shields.io/badge/changed-orange?style=flat) | New |
|------------------------------------------------------------------------------------|-----------------------------------|
| `k8s.replicationcontroller.name` | `k8s.replication_controller.name` |
| `k8s.replicationcontroller.uid` | `k8s.replication_controller.uid` |

<!-- prettier-ignore-end -->

### K8s ResourceQuota attributes

The K8s ResourceQuota attributes implemented by the Collector and specifically the
[k8scluster](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.115.0/receiver/k8sclusterreceiver/documentation.md)
receiver were introduced as semantic conventions in
[#1649](https://github.com/open-telemetry/semantic-conventions/pull/1742) (TODO: replace with SemConv version once
available).

The changes are the following:

<!-- prettier-ignore-start -->

| Old (Collector) ![changed](https://img.shields.io/badge/changed-orange?style=flat) | New |
|----------------------------------------------------------------------------------|-----------------------------------|
| `k8s.resourcequota.name` | `k8s.resource_quota.name` |
| `k8s.resourcequota.uid` | `k8s.resource_quota.uid` |

<!-- prettier-ignore-end -->
85 changes: 85 additions & 0 deletions docs/resource/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,89 @@ A CronJob creates Jobs on a repeating schedule.
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## ReplicationController

A ReplicationController ensures that a specified number of pod replicas are running at any one time.

<!-- semconv resource.k8s.replication_controller -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->


**Status:** ![Experimental](https://img.shields.io/badge/-experimental-blue)

**type:** `k8s.replication_controller`

**Description:** A Kubernetes ReplicationController object.

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`k8s.replication_controller.name`](/docs/attributes-registry/k8s.md) | string | The name of the replication controller. | `opentelemetry` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`k8s.replication_controller.uid`](/docs/attributes-registry/k8s.md) | string | The UID of the replication controller. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## HorizontalPodAutoscaler

A HorizontalPodAutoscaler (HPA for short) automatically updates a workload resource
(such as a Deployment or StatefulSet), with the aim of automatically scaling the workload to match demand.

<!-- semconv resource.k8s.hpa -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->


**Status:** ![Experimental](https://img.shields.io/badge/-experimental-blue)

**type:** `k8s.hpa`

**Description:** A Kubernetes HorizontalPodAutoscaler object.

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`k8s.hpa.name`](/docs/attributes-registry/k8s.md) | string | The name of the horizontal pod autoscaler. | `opentelemetry` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`k8s.hpa.uid`](/docs/attributes-registry/k8s.md) | string | The UID of the horizontal pod autoscaler. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## ResourceQuota

A ResourceQuota provides constraints that limit aggregate resource consumption per namespace.

<!-- semconv resource.k8s.resource_quota -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->
<!-- markdownlint-capture -->
<!-- markdownlint-disable -->


**Status:** ![Experimental](https://img.shields.io/badge/-experimental-blue)

**type:** `k8s.resource_quota`

**Description:** A Kubernetes ResourceQuota object.

| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
|---|---|---|---|---|---|
| [`k8s.resource_quota.name`](/docs/attributes-registry/k8s.md) | string | The name of the resource quota. | `opentelemetry` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |
| [`k8s.resource_quota.uid`](/docs/attributes-registry/k8s.md) | string | The UID of the resource quota. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | `Recommended` | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
18 changes: 18 additions & 0 deletions docs/system/k8s-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ This metric is [recommended][MetricRecommended].
**[1]:** This metric aligns with the `replicas` field of the
[K8s ReplicationControllerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core)

This metric SHOULD, at a minimum, be reported against a
[`k8s.replication_controller`](../resource/k8s.md#replicationcontroller) resource.

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
Expand All @@ -549,6 +552,9 @@ This metric is [recommended][MetricRecommended].
**[1]:** This metric aligns with the `availableReplicas` field of the
[K8s ReplicationControllerStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core)

This metric SHOULD, at a minimum, be reported against a
[`k8s.replication_controller`](../resource/k8s.md#replicationcontroller) resource.

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
Expand Down Expand Up @@ -684,6 +690,9 @@ This metric is [recommended][MetricRecommended].
**[1]:** This metric aligns with the `desiredReplicas` field of the
[K8s HorizontalPodAutoscalerStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling)

This metric SHOULD, at a minimum, be reported against a
[`k8s.hpa`](../resource/k8s.md#horizontalpodautoscaler) resource.

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
Expand All @@ -707,6 +716,9 @@ This metric is [recommended][MetricRecommended].
**[1]:** This metric aligns with the `currentReplicas` field of the
[K8s HorizontalPodAutoscalerStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling)

This metric SHOULD, at a minimum, be reported against a
[`k8s.hpa`](../resource/k8s.md#horizontalpodautoscaler) resource.

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
Expand All @@ -730,6 +742,9 @@ This metric is [recommended][MetricRecommended].
**[1]:** This metric aligns with the `maxReplicas` field of the
[K8s HorizontalPodAutoscalerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling)

This metric SHOULD, at a minimum, be reported against a
[`k8s.hpa`](../resource/k8s.md#horizontalpodautoscaler) resource.

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
Expand All @@ -753,6 +768,9 @@ This metric is [recommended][MetricRecommended].
**[1]:** This metric aligns with the `minReplicas` field of the
[K8s HorizontalPodAutoscalerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling)

This metric SHOULD, at a minimum, be reported against a
[`k8s.hpa`](../resource/k8s.md#horizontalpodautoscaler) resource.

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
Expand Down
18 changes: 18 additions & 0 deletions model/k8s/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ groups:
note: |
This metric aligns with the `replicas` field of the
[K8s ReplicationControllerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core)
This metric SHOULD, at a minimum, be reported against a
[`k8s.replication_controller`](../resource/k8s.md#replicationcontroller) resource.
instrument: updowncounter
unit: "{pod}"
- id: metric.k8s.replication_controller.available_pods
Expand All @@ -204,6 +207,9 @@ groups:
note: |
This metric aligns with the `availableReplicas` field of the
[K8s ReplicationControllerStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core)
This metric SHOULD, at a minimum, be reported against a
[`k8s.replication_controller`](../resource/k8s.md#replicationcontroller) resource.
instrument: updowncounter
unit: "{pod}"

Expand Down Expand Up @@ -271,6 +277,9 @@ groups:
note: |
This metric aligns with the `desiredReplicas` field of the
[K8s HorizontalPodAutoscalerStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling)
This metric SHOULD, at a minimum, be reported against a
[`k8s.hpa`](../resource/k8s.md#horizontalpodautoscaler) resource.
instrument: updowncounter
unit: "{pod}"
- id: metric.k8s.hpa.current_pods
Expand All @@ -282,6 +291,9 @@ groups:
note: |
This metric aligns with the `currentReplicas` field of the
[K8s HorizontalPodAutoscalerStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling)
This metric SHOULD, at a minimum, be reported against a
[`k8s.hpa`](../resource/k8s.md#horizontalpodautoscaler) resource.
instrument: updowncounter
unit: "{pod}"
- id: metric.k8s.hpa.max_pods
Expand All @@ -293,6 +305,9 @@ groups:
note: |
This metric aligns with the `maxReplicas` field of the
[K8s HorizontalPodAutoscalerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling)
This metric SHOULD, at a minimum, be reported against a
[`k8s.hpa`](../resource/k8s.md#horizontalpodautoscaler) resource.
instrument: updowncounter
unit: "{pod}"
- id: metric.k8s.hpa.min_pods
Expand All @@ -304,6 +319,9 @@ groups:
note: |
This metric aligns with the `minReplicas` field of the
[K8s HorizontalPodAutoscalerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling)
This metric SHOULD, at a minimum, be reported against a
[`k8s.hpa`](../resource/k8s.md#horizontalpodautoscaler) resource.
instrument: updowncounter
unit: "{pod}"

Expand Down
36 changes: 36 additions & 0 deletions model/k8s/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,30 @@ groups:
brief: >
The name of the ReplicaSet.
examples: ['opentelemetry']
- id: k8s.replication_controller.uid
type: string
stability: experimental
brief: >
The UID of the replication controller.
examples: [ '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' ]
- id: k8s.replication_controller.name
type: string
stability: experimental
brief: >
The name of the replication controller.
examples: [ 'opentelemetry' ]
- id: k8s.resource_quota.uid
type: string
stability: experimental
brief: >
The UID of the resource quota.
examples: [ '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' ]
- id: k8s.resource_quota.name
type: string
stability: experimental
brief: >
The name of the resource quota.
examples: [ 'opentelemetry' ]
- id: k8s.deployment.uid
type: string
stability: experimental
Expand Down Expand Up @@ -153,6 +177,18 @@ groups:
brief: >
The name of the DaemonSet.
examples: ['opentelemetry']
- id: k8s.hpa.uid
type: string
stability: experimental
brief: >
The UID of the horizontal pod autoscaler.
examples: ['275ecb36-5aa8-4c2a-9c47-d8bb681b9aff']
- id: k8s.hpa.name
type: string
stability: experimental
brief: >
The name of the horizontal pod autoscaler.
examples: ['opentelemetry']
- id: k8s.job.uid
type: string
stability: experimental
Expand Down
Loading

0 comments on commit ec47412

Please sign in to comment.