Skip to content

Commit

Permalink
Add uptime metrics for container, k8s Pod and k8s Node
Browse files Browse the repository at this point in the history
Signed-off-by: ChrsMark <[email protected]>
  • Loading branch information
ChrsMark committed Nov 26, 2024
1 parent a6dfa97 commit 361146e
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .chloggen/add_k8s_uptime_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 uptime metrics for container, K8s Pod and K8s Node

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

# (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:
24 changes: 24 additions & 0 deletions docs/system/container-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ This document describes instruments and attributes for common container level
metrics in OpenTelemetry. These metrics are collected from technology-specific,
well-defined APIs (e.g. Kubelet's API or container runtimes).

### Metric: `container.uptime`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.container.uptime -->
<!-- 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 |
| -------- | --------------- | ----------- | -------------- | --------- |
| `container.uptime` | Gauge | `s` | The time the container has been running [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.

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

### Metric: `container.cpu.time`

This metric is [opt-in][MetricOptIn].
Expand Down Expand Up @@ -198,3 +221,4 @@ This metric is [opt-in][MetricOptIn].

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status
[MetricOptIn]: /docs/general/metric-requirement-level.md#opt-in
[MetricRecommended]: /docs/general/metric-requirement-level.md#recommended
46 changes: 46 additions & 0 deletions docs/system/k8s-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ well-defined APIs (e.g. Kubelet's API).
Metrics in `k8s.` instruments SHOULD be attached to a [K8s Resource](/docs/resource/k8s.md)
and therefore inherit its attributes, like `k8s.pod.name` and `k8s.pod.uid`.

### Metric: `k8s.pod.uptime`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.k8s.pod.uptime -->
<!-- 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.pod.uptime` | Gauge | `s` | The time the Pod has been running [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.

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

### Metric: `k8s.pod.cpu.time`

This metric is [recommended][MetricRecommended].
Expand Down Expand Up @@ -149,6 +172,29 @@ This metric is [recommended][MetricRecommended].
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

### Metric: `k8s.node.uptime`

This metric is [recommended][MetricRecommended].

<!-- semconv metric.k8s.node.uptime -->
<!-- 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.node.uptime` | Gauge | `s` | The time the Node has been running [1] | ![Experimental](https://img.shields.io/badge/-experimental-blue) |

**[1]:** Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.

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

### Metric: `k8s.node.cpu.time`

This metric is [recommended][MetricRecommended].
Expand Down
11 changes: 11 additions & 0 deletions model/container/metrics.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
groups:
# container.* metrics
- id: metric.container.uptime
type: metric
metric_name: container.uptime
stability: experimental
brief: "The time the container has been running"
note: |
Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.
instrument: gauge
unit: "s"
# container.cpu.* metrics and attribute group
- id: metric.container.cpu.time
type: metric
Expand Down
22 changes: 22 additions & 0 deletions model/k8s/metrics.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
groups:
# k8s.pod.* metrics
- id: metric.k8s.pod.uptime
type: metric
metric_name: k8s.pod.uptime
stability: experimental
brief: "The time the Pod has been running"
note: |
Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.
instrument: gauge
unit: "s"
# k8s.pod.cpu.* metrics
- id: metric.k8s.pod.cpu.time
type: metric
Expand Down Expand Up @@ -52,6 +63,17 @@ groups:
- ref: network.interface.name
- ref: network.io.direction

# k8s.node.* metrics
- id: metric.k8s.node.uptime
type: metric
metric_name: k8s.node.uptime
stability: experimental
brief: "The time the Node has been running"
note: |
Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.
instrument: gauge
unit: "s"
# k8s.node.cpu.* metrics
- id: metric.k8s.node.cpu.time
type: metric
Expand Down

0 comments on commit 361146e

Please sign in to comment.