Skip to content

Commit 585c4c3

Browse files
ChrsMarkjinja2
andauthored
(k8s): add CPU limit/request utilization metrics for pod and container (#2514)
Signed-off-by: ChrsMark <[email protected]> Co-authored-by: Jina Jain <[email protected]>
1 parent 3e02eaf commit 585c4c3

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 container CPU limit/request utilization metrics."
14+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
15+
# The values here must be integers.
16+
issues: [1489]
17+
18+
# (Optional) One or more lines of additional information to render under the primary note.
19+
# These lines will be padded with 2 spaces and then inserted directly into the document.
20+
# Use pipe (|) for multiline entries.
21+
subtext:

docs/non-normative/k8s-migration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ The changes in their metrics are the following:
335335
| `k8s.container.ephemeralstorage_request` (type: `gauge`) | `k8s.container.ephemeral_storage.request` (type: `updowncounter`) |
336336
| `k8s.container.restarts` (type: `gauge`) | `k8s.container.restart.count` (type: `updowncounter`) |
337337
| `k8s.container.ready` (type: `gauge`) | `k8s.container.ready` (type: `updowncounter`) |
338+
| `k8s.container.cpu_limit_utilization` (type: `gauge`) | `k8s.container.cpu.limit_utilization` (type: `gauge`) |
339+
| `k8s.container.cpu_request_utilization` (type: `gauge`) | `k8s.container.cpu.request_utilization` (type: `gauge`) |
338340

339341
<!-- prettier-ignore-end -->
340342

docs/system/k8s-metrics.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ and therefore inherit its attributes, like `k8s.pod.name` and `k8s.pod.uid`.
8989
- [Namespace metrics](#namespace-metrics)
9090
- [Metric: `k8s.namespace.phase`](#metric-k8snamespacephase)
9191
- [K8s Container metrics](#k8s-container-metrics)
92+
- [Metric: `k8s.container.cpu.limit_utilization`](#metric-k8scontainercpulimit_utilization)
93+
- [Metric: `k8s.container.cpu.request_utilization`](#metric-k8scontainercpurequest_utilization)
9294
- [Metric: `k8s.container.cpu.limit`](#metric-k8scontainercpulimit)
9395
- [Metric: `k8s.container.cpu.request`](#metric-k8scontainercpurequest)
9496
- [Metric: `k8s.container.memory.limit`](#metric-k8scontainermemorylimit)
@@ -1817,6 +1819,48 @@ This metric is [recommended][MetricRecommended].
18171819

18181820
**Description:** K8s Container level metrics captured under the namespace `k8s.container`.
18191821

1822+
### Metric: `k8s.container.cpu.limit_utilization`
1823+
1824+
This metric is [recommended][MetricRecommended].
1825+
1826+
<!-- semconv metric.k8s.container.cpu.limit_utilization -->
1827+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
1828+
<!-- see templates/registry/markdown/snippet.md.j2 -->
1829+
<!-- prettier-ignore-start -->
1830+
<!-- markdownlint-capture -->
1831+
<!-- markdownlint-disable -->
1832+
1833+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
1834+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
1835+
| `k8s.container.cpu.limit_utilization` | Gauge | `1` | The ratio of container CPU usage to its CPU limit. [1] | ![Development](https://img.shields.io/badge/-development-blue) | [`k8s.container`](/docs/registry/entities/k8s.md#k8s-container) |
1836+
1837+
**[1]:** The value range is [0.0,1.0]. A value of 1.0 means the container is using 100% of its CPU limit. If the CPU limit is not set, this metric SHOULD NOT be emitted for that container.
1838+
1839+
<!-- markdownlint-restore -->
1840+
<!-- prettier-ignore-end -->
1841+
<!-- END AUTOGENERATED TEXT -->
1842+
<!-- endsemconv -->
1843+
1844+
### Metric: `k8s.container.cpu.request_utilization`
1845+
1846+
This metric is [recommended][MetricRecommended].
1847+
1848+
<!-- semconv metric.k8s.container.cpu.request_utilization -->
1849+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
1850+
<!-- see templates/registry/markdown/snippet.md.j2 -->
1851+
<!-- prettier-ignore-start -->
1852+
<!-- markdownlint-capture -->
1853+
<!-- markdownlint-disable -->
1854+
1855+
| Name | Instrument Type | Unit (UCUM) | Description | Stability | Entity Associations |
1856+
| -------- | --------------- | ----------- | -------------- | --------- | ------ |
1857+
| `k8s.container.cpu.request_utilization` | Gauge | `1` | The ratio of container CPU usage to its CPU request. | ![Development](https://img.shields.io/badge/-development-blue) | [`k8s.container`](/docs/registry/entities/k8s.md#k8s-container) |
1858+
1859+
<!-- markdownlint-restore -->
1860+
<!-- prettier-ignore-end -->
1861+
<!-- END AUTOGENERATED TEXT -->
1862+
<!-- endsemconv -->
1863+
18201864
### Metric: `k8s.container.cpu.limit`
18211865

18221866
This metric is [recommended][MetricRecommended].

model/k8s/metrics.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,32 @@ groups:
11421142
note: |
11431143
This metric SHOULD reflect the value of the `ready` field in the
11441144
[K8s ContainerStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatus-v1-core).
1145+
- id: metric.k8s.container.cpu.limit_utilization
1146+
type: metric
1147+
metric_name: k8s.container.cpu.limit_utilization
1148+
annotations:
1149+
code_generation:
1150+
metric_value_type: double
1151+
stability: development
1152+
brief: "The ratio of container CPU usage to its CPU limit."
1153+
entity_associations:
1154+
- k8s.container
1155+
note: >
1156+
The value range is [0.0,1.0]. A value of 1.0 means the container is using 100% of its CPU limit. If the CPU limit is not set, this metric SHOULD NOT be emitted for that container.
1157+
instrument: gauge
1158+
unit: "1"
1159+
- id: metric.k8s.container.cpu.request_utilization
1160+
type: metric
1161+
metric_name: k8s.container.cpu.request_utilization
1162+
annotations:
1163+
code_generation:
1164+
metric_value_type: double
1165+
stability: development
1166+
brief: "The ratio of container CPU usage to its CPU request."
1167+
entity_associations:
1168+
- k8s.container
1169+
instrument: gauge
1170+
unit: "1"
11451171

11461172
# k8s.resourcequota.cpu.* metrics
11471173
- id: metric.k8s.resourcequota.cpu.limit.hard

0 commit comments

Comments
 (0)