Skip to content

Commit 6abebd8

Browse files
committed
Add memory metrics for k8s.pod, k8s.node and container
Signed-off-by: ChrsMark <[email protected]>
1 parent 5ee549b commit 6abebd8

File tree

6 files changed

+661
-0
lines changed

6 files changed

+661
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use this changelog template to create an entry for release notes.
2+
#
3+
# If your change doesn't affect end users you should instead start
4+
# your pull request title with [chore] or use the "Skip Changelog" label.
5+
6+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
7+
change_type: enhancement
8+
9+
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
10+
component: k8s
11+
12+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
13+
note: Add memory metrics for k8s.node, k8s.pod and container resources
14+
15+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
16+
# The values here must be integers.
17+
issues: [2776]
18+
19+
# (Optional) One or more lines of additional information to render under the primary note.
20+
# These lines will be padded with 2 spaces and then inserted directly into the document.
21+
# Use pipe (|) for multiline entries.
22+
subtext:

docs/non-normative/k8s-migration.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ and one for disabling the old schema called `semconv.k8s.disableLegacy`. Then:
6363
- [K8s Node condition metrics](#k8s-node-condition-metrics)
6464
- [K8s Filesystem metrics](#k8s-filesystem-metrics)
6565
- [K8s Pod Volume metrics](#k8s-pod-volume-metrics)
66+
- [K8s Pod Memory metrics](#k8s-pod-memory-metrics)
67+
- [Container memory metrics](#container-memory-metrics)
68+
- [K8s Node memory metrics](#k8s-node-memory-metrics)
6669
- [Container Runtime](#container-runtime)
6770

6871
<!-- tocstop -->
@@ -422,6 +425,60 @@ The changes in these metrics are the following:
422425

423426
<!-- prettier-ignore-end -->
424427

428+
### K8s Pod Memory metrics
429+
430+
The K8s Pod memory metrics implemented by the Collector and specifically the
431+
[k8scluster](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.119.0/receiver/k8sclusterreceiver/documentation.md)
432+
receiver were introduced as semantic conventions in
433+
[#1490](https://github.com/open-telemetry/semantic-conventions/issues/1490).
434+
435+
The changes in these metrics are the following:
436+
437+
<!-- prettier-ignore-start -->
438+
439+
| Old (Collector) ![changed](https://img.shields.io/badge/changed-orange?style=flat) | New |
440+
|------------------------------------------------------------------------------------|------------------------------------------------|
441+
| `k8s.pod.memory.page_faults` | `k8s.pod.memory.paging.faults` with attribute `system.paging.type` |
442+
| `k8s.pod.memory.major_page_faults` | `k8s.pod.memory.paging.faults` with attribute `system.paging.type` |
443+
444+
<!-- prettier-ignore-end -->
445+
446+
### Container memory metrics
447+
448+
The Container memory metrics implemented by the Collector and specifically the
449+
[k8scluster](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.119.0/receiver/k8sclusterreceiver/documentation.md)
450+
receiver were introduced as semantic conventions in
451+
[#1490](https://github.com/open-telemetry/semantic-conventions/issues/1490).
452+
453+
The changes in these metrics are the following:
454+
455+
<!-- prettier-ignore-start -->
456+
457+
| Old (Collector) ![changed](https://img.shields.io/badge/changed-orange?style=flat) | New |
458+
|------------------------------------------------------------------------------------|---------------------------------------------------------------|
459+
| `container.memory.page_faults` | `container.memory.paging.faults` with attribute `system.paging.type` |
460+
| `container.memory.major_page_faults` | `container.memory.paging.faults` with attribute `system.paging.type` |
461+
462+
<!-- prettier-ignore-end -->
463+
464+
### K8s Node memory metrics
465+
466+
The K8s Node memory metrics implemented by the Collector and specifically the
467+
[k8scluster](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.119.0/receiver/k8sclusterreceiver/documentation.md)
468+
receiver were introduced as semantic conventions in
469+
[#1490](https://github.com/open-telemetry/semantic-conventions/issues/1490).
470+
471+
The changes in these metrics are the following:
472+
473+
<!-- prettier-ignore-start -->
474+
475+
| Old (Collector) ![changed](https://img.shields.io/badge/changed-orange?style=flat) | New |
476+
|------------------------------------------------------------------------------------|---------------------------------------------------------------------|
477+
| `k8s.node.memory.page_faults` | `k8s.node.memory.paging.faults` with attribute `system.paging.type` |
478+
| `k8s.node.memory.major_page_faults` | `k8s.node.memory.paging.faults` with attribute `system.paging.type` |
479+
480+
<!-- prettier-ignore-end -->
481+
425482
### Container Runtime
426483

427484
The container runtime has become more descriptive with changes introduced to semantic conventions

docs/system/container-metrics.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ well-defined APIs (e.g. Kubelet's API or container runtimes).
1818
- [Metric: `container.cpu.time`](#metric-containercputime)
1919
- [Metric: `container.cpu.usage`](#metric-containercpuusage)
2020
- [Metric: `container.memory.usage`](#metric-containermemoryusage)
21+
- [Metric: `container.memory.available`](#metric-containermemoryavailable)
22+
- [Metric: `container.memory.rss`](#metric-containermemoryrss)
23+
- [Metric: `container.memory.working_set`](#metric-containermemoryworking_set)
24+
- [Metric: `container.memory.paging.faults`](#metric-containermemorypagingfaults)
2125
- [Metric: `container.disk.io`](#metric-containerdiskio)
2226
- [Metric: `container.network.io`](#metric-containernetworkio)
2327
- [Metric: `container.filesystem.available`](#metric-containerfilesystemavailable)
@@ -161,6 +165,112 @@ This metric is [opt-in][MetricOptIn].
161165
<!-- END AUTOGENERATED TEXT -->
162166
<!-- endsemconv -->
163167

168+
### Metric: `container.memory.available`
169+
170+
This metric is [opt-in][MetricOptIn].
171+
172+
<!-- semconv metric.container.memory.available -->
173+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
174+
<!-- see templates/registry/markdown/snippet.md.j2 -->
175+
<!-- prettier-ignore-start -->
176+
<!-- markdownlint-capture -->
177+
<!-- markdownlint-disable -->
178+
179+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
180+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
181+
| `container.memory.available` | Gauge | `By` | Container memory available [1] | ![Development](https://img.shields.io/badge/-development-blue) | [`container`](/docs/registry/entities/container.md#container) |
182+
183+
**[1]:** Available memory for use. This is defined as the memory limit - workingSetBytes. If memory limit is undefined, the available bytes is omitted.
184+
In general, this metric can be derived from [cadvisor](https://github.com/google/cadvisor/blob/v0.53.0/docs/storage/prometheus.md#prometheus-container-metrics) and by subtracting the `container_memory_working_set_bytes` metric from the `container_spec_memory_limit_bytes` metric.
185+
In K8s, this metric is derived from the [MemoryStats.AvailableBytes](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats) field of the [PodStats.Memory](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats) of the Kubelet's stats API.
186+
187+
<!-- markdownlint-restore -->
188+
<!-- prettier-ignore-end -->
189+
<!-- END AUTOGENERATED TEXT -->
190+
<!-- endsemconv -->
191+
192+
### Metric: `container.memory.rss`
193+
194+
This metric is [opt-in][MetricOptIn].
195+
196+
<!-- semconv metric.container.memory.rss -->
197+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
198+
<!-- see templates/registry/markdown/snippet.md.j2 -->
199+
<!-- prettier-ignore-start -->
200+
<!-- markdownlint-capture -->
201+
<!-- markdownlint-disable -->
202+
203+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
204+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
205+
| `container.memory.rss` | Gauge | `By` | Container memory RSS [1] | ![Development](https://img.shields.io/badge/-development-blue) | [`container`](/docs/registry/entities/container.md#container) |
206+
207+
**[1]:** In general, this metric can be derived from [cadvisor](https://github.com/google/cadvisor/blob/v0.53.0/docs/storage/prometheus.md#prometheus-container-metrics) and specifically the `container_memory_rss` metric.
208+
In K8s, this metric is derived from the [MemoryStats.RSSBytes](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats) field of the [PodStats.Memory](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats) of the Kubelet's stats API.
209+
210+
<!-- markdownlint-restore -->
211+
<!-- prettier-ignore-end -->
212+
<!-- END AUTOGENERATED TEXT -->
213+
<!-- endsemconv -->
214+
215+
### Metric: `container.memory.working_set`
216+
217+
This metric is [opt-in][MetricOptIn].
218+
219+
<!-- semconv metric.container.memory.working_set -->
220+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
221+
<!-- see templates/registry/markdown/snippet.md.j2 -->
222+
<!-- prettier-ignore-start -->
223+
<!-- markdownlint-capture -->
224+
<!-- markdownlint-disable -->
225+
226+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
227+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
228+
| `container.memory.working_set` | Gauge | `By` | Container memory working set [1] | ![Development](https://img.shields.io/badge/-development-blue) | [`container`](/docs/registry/entities/container.md#container) |
229+
230+
**[1]:** In general, this metric can be derived from [cadvisor](https://github.com/google/cadvisor/blob/v0.53.0/docs/storage/prometheus.md#prometheus-container-metrics) and specifically the `container_memory_working_set_bytes` metric.
231+
In K8s, this metric is derived from the [MemoryStats.WorkingSetBytes](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats) field of the [PodStats.Memory](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats) of the Kubelet's stats API.
232+
233+
<!-- markdownlint-restore -->
234+
<!-- prettier-ignore-end -->
235+
<!-- END AUTOGENERATED TEXT -->
236+
<!-- endsemconv -->
237+
238+
### Metric: `container.memory.paging.faults`
239+
240+
This metric is [opt-in][MetricOptIn].
241+
242+
<!-- semconv metric.container.memory.paging.faults -->
243+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
244+
<!-- see templates/registry/markdown/snippet.md.j2 -->
245+
<!-- prettier-ignore-start -->
246+
<!-- markdownlint-capture -->
247+
<!-- markdownlint-disable -->
248+
249+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
250+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
251+
| `container.memory.paging.faults` | Counter | `{fault}` | Container memory paging faults [1] | ![Development](https://img.shields.io/badge/-development-blue) | [`container`](/docs/registry/entities/container.md#container) |
252+
253+
**[1]:** In general, this metric can be derived from [cadvisor](https://github.com/google/cadvisor/blob/v0.53.0/docs/storage/prometheus.md#prometheus-container-metrics) and specifically the `container_memory_failures_total{failure_type=pgfault, scope=container}` and `container_memory_failures_total{failure_type=pgmajfault, scope=container}`metric.
254+
In K8s, this metric is derived from the [MemoryStats.PageFaults](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats) and [MemoryStats.MajorPageFaults](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#MemoryStats) field of the [PodStats.Memory](https://pkg.go.dev/k8s.io/[email protected]/pkg/apis/stats/v1alpha1#PodStats) of the Kubelet's stats API.
255+
256+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
257+
|---|---|---|---|---|---|
258+
| [`system.paging.type`](/docs/registry/attributes/system.md) | string | The memory paging type | `minor` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) |
259+
260+
---
261+
262+
`system.paging.type` 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.
263+
264+
| Value | Description | Stability |
265+
|---|---|---|
266+
| `major` | major | ![Development](https://img.shields.io/badge/-development-blue) |
267+
| `minor` | minor | ![Development](https://img.shields.io/badge/-development-blue) |
268+
269+
<!-- markdownlint-restore -->
270+
<!-- prettier-ignore-end -->
271+
<!-- END AUTOGENERATED TEXT -->
272+
<!-- endsemconv -->
273+
164274
### Metric: `container.disk.io`
165275

166276
This metric is [opt-in][MetricOptIn].

0 commit comments

Comments
 (0)