Skip to content

Commit 5075ca7

Browse files
authored
Add memory metrics for k8s.pod, k8s.node and container (#2776)
Signed-off-by: ChrsMark <[email protected]>
1 parent 21ba973 commit 5075ca7

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
- [K8s Pod Status Phase and Reason](#k8s-pod-status-phase-and-reason)
6871

@@ -423,6 +426,60 @@ The changes in these metrics are the following:
423426

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

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

428485
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` | UpDownCounter | `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` | UpDownCounter | `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` | UpDownCounter | `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)