Skip to content

Commit

Permalink
Add k8s daemonset metrics
Browse files Browse the repository at this point in the history
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
  • Loading branch information
ChrsMark committed Dec 17, 2024
1 parent b60cdba commit 52eee4c
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .chloggen/add_ds_metrics.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 k8s deamonset related metrics

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

# (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:
22 changes: 22 additions & 0 deletions docs/non-normative/k8s-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and one for disabling the old schema called `semconv.k8s.disableLegacy`. Then:
- [K8s ReplicationController metrics](#k8s-replicationcontroller-metrics)
- [K8s StatefulsSet metrics](#k8s-statefulsset-metrics)
- [K8s HorizontalPodAutoscaler metrics](#k8s-horizontalpodautoscaler-metrics)
- [K8s DaemonSet metrics](#k8s-daemonset-metrics)

<!-- tocstop -->

Expand Down Expand Up @@ -173,3 +174,24 @@ The changes in their metric names and types are the following:
| `k8s.hpa.min_replicas` (type: `gauge`) | `k8s.hpa.min_pods` (type: `updowncounter`) |

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

### K8s DaemonSet metrics

The K8s DaemonSet metrics 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/1649) (TODO: replace with SemConv version once
available).

The changes in their metric types are the following:

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

| Old (Collector) ![changed](https://img.shields.io/badge/changed-orange?style=flat) | New |
|------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| `k8s.daemonset.current_scheduled_nodes` (type: `gauge`) | `k8s.daemonset.current_scheduled_nodes` (type: `updowncounter`) |
| `k8s.daemonset.desired_scheduled_nodes` (type: `gauge`) | `k8s.daemonset.desired_scheduled_nodes` (type: `updowncounter`) |
| `k8s.daemonset.misscheduled_nodes` (type: `gauge`) | `k8s.daemonset.misscheduled_nodes` (type: `updowncounter`) |
| `k8s.daemonset.ready_nodes` (type: `gauge`) | `k8s.daemonset.ready_nodes` (type: `updowncounter`) |

<!-- prettier-ignore-end -->
113 changes: 113 additions & 0 deletions docs/system/k8s-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ and therefore inherit its attributes, like `k8s.pod.name` and `k8s.pod.uid`.
- [Metric: `k8s.hpa.current_pods`](#metric-k8shpacurrent_pods)
- [Metric: `k8s.hpa.max_pods`](#metric-k8shpamax_pods)
- [Metric: `k8s.hpa.min_pods`](#metric-k8shpamin_pods)
- [Daemonset Metrics](#daemonset-metrics)
- [Metric: `k8s.daemonset.current_scheduled_nodes`](#metric-k8sdaemonsetcurrent_scheduled_nodes)
- [Metric: `k8s.daemonset.desired_scheduled_nodes`](#metric-k8sdaemonsetdesired_scheduled_nodes)
- [Metric: `k8s.daemonset.misscheduled_nodes`](#metric-k8sdaemonsetmisscheduled_nodes)
- [Metric: `k8s.daemonset.ready_nodes`](#metric-k8sdaemonsetready_nodes)

<!-- tocstop -->

Expand Down Expand Up @@ -743,5 +748,113 @@ This metric is [recommended][MetricRecommended].
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## Daemonset Metrics

**Description:** Daemonset level metrics captured under the namespace `k8s.daemonset`.

### Metric: `k8s.daemonset.current_scheduled_nodes`

This metric is [recommended][MetricRecommended].

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

| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `k8s.daemonset.current_scheduled_nodes` | UpDownCounter | `{node}` | Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** This metric aligns with the `currentNumberScheduled` field of the
[K8s DaemonSetStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps).

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

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

### Metric: `k8s.daemonset.desired_scheduled_nodes`

This metric is [recommended][MetricRecommended].

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

| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `k8s.daemonset.desired_scheduled_nodes` | UpDownCounter | `{node}` | Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod) [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** This metric aligns with the `desiredNumberScheduled` field of the
[K8s DaemonSetStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps).

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

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

### Metric: `k8s.daemonset.misscheduled_nodes`

This metric is [recommended][MetricRecommended].

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

| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `k8s.daemonset.misscheduled_nodes` | UpDownCounter | `{node}` | Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** This metric aligns with the `numberMisscheduled` field of the
[K8s DaemonSetStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps).

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

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

### Metric: `k8s.daemonset.ready_nodes`

This metric is [recommended][MetricRecommended].

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

| Name | Instrument Type | Unit (UCUM) | Description | Stability |
| -------- | --------------- | ----------- | -------------- | --------- |
| `k8s.daemonset.ready_nodes` | UpDownCounter | `{node}` | Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** This metric aligns with the `numberReady` field of the
[K8s DaemonSetStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps).

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

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

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
[MetricRecommended]: /docs/general/metric-requirement-level.md#recommended
54 changes: 54 additions & 0 deletions model/k8s/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,57 @@ groups:
[K8s HorizontalPodAutoscalerSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling)
instrument: updowncounter
unit: "{pod}"

# k8s.daemonset.* metrics
- id: metric.k8s.daemonset.current_scheduled_nodes
type: metric
metric_name: k8s.daemonset.current_scheduled_nodes
stability: experimental
brief: "Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod"
note: |
This metric aligns with the `currentNumberScheduled` field of the
[K8s DaemonSetStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps).
This metric SHOULD, at a minimum, be reported against a
[`k8s.daemonset`](../resource/k8s.md#daemonset) resource.
instrument: updowncounter
unit: "{node}"
- id: metric.k8s.daemonset.desired_scheduled_nodes
type: metric
metric_name: k8s.daemonset.desired_scheduled_nodes
stability: experimental
brief: "Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)"
note: |
This metric aligns with the `desiredNumberScheduled` field of the
[K8s DaemonSetStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps).
This metric SHOULD, at a minimum, be reported against a
[`k8s.daemonset`](../resource/k8s.md#daemonset) resource.
instrument: updowncounter
unit: "{node}"
- id: metric.k8s.daemonset.misscheduled_nodes
type: metric
metric_name: k8s.daemonset.misscheduled_nodes
stability: experimental
brief: "Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod"
note: |
This metric aligns with the `numberMisscheduled` field of the
[K8s DaemonSetStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps).
This metric SHOULD, at a minimum, be reported against a
[`k8s.daemonset`](../resource/k8s.md#daemonset) resource.
instrument: updowncounter
unit: "{node}"
- id: metric.k8s.daemonset.ready_nodes
type: metric
metric_name: k8s.daemonset.ready_nodes
stability: experimental
brief: "Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready"
note: |
This metric aligns with the `numberReady` field of the
[K8s DaemonSetStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps).
This metric SHOULD, at a minimum, be reported against a
[`k8s.daemonset`](../resource/k8s.md#daemonset) resource.
instrument: updowncounter
unit: "{node}"

0 comments on commit 52eee4c

Please sign in to comment.