Skip to content

Commit 9a57b62

Browse files
authored
[receiver/kubeletstats] Move receiver.kubeletstats.enableCPUUsageMetrics feature gate to beta (#39488)
<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes #39487 Related to #27885 --------- Signed-off-by: odubajDT <[email protected]>
1 parent 13b1771 commit 9a57b62

17 files changed

+322
-320
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: receiver/kubeletstats
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Move receiver.kubeletstats.enableCPUUsageMetrics feature gate to beta
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39487]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
Deprecated metrics `container.cpu.utilization`, `k8s.pod.cpu.utilization` and `k8s.node.cpu.utilization` are being replaced
20+
by `container.cpu.usage`, `k8s.pod.cpu.usage` and `k8s.node.cpu.usage`.
21+
To be able to use the deprecated metrics, switch `receiver.kubeletstats.enableCPUUsageMetrics` feature gate to `false`.
22+
23+
# If your change doesn't affect end users or the exported elements of any package,
24+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
25+
# Optional: The change log or logs in which this entry should be included.
26+
# e.g. '[user]' or '[user, api]'
27+
# Include 'user' if the change is relevant to end users.
28+
# Include 'api' if there is a change to a library API.
29+
# Default: '[user]'
30+
change_logs: []

receiver/kubeletstatsreceiver/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
The Kubelet Stats Receiver pulls node, pod, container, and volume metrics from the API server on a kubelet
1717
and sends it down the metric pipeline for further processing.
1818

19+
> [!WARNING]
20+
> The `receiver.kubeletstats.enableCPUUsageMetrics` feature gate was moved to stage `Beta` what results in a breaking change in metrics names.
21+
> For more information which metrics are affected see [here](#metrics-deprecation).
22+
1923
## Metrics
2024

2125
Details about the metrics produced by this receiver can be found in [metadata.yaml](./metadata.yaml) with further documentation in [documentation.md](./documentation.md)
@@ -308,16 +312,19 @@ rules:
308312
verbs: ["get"]
309313
```
310314

311-
### Warning about metrics' deprecation
315+
### Metrics deprecation
316+
317+
The following metrics were deprecated and renamed from version `v0.125.0`:
312318

313-
The following metrics will be renamed in a future version:
314319
- `k8s.node.cpu.utilization` (renamed to `k8s.node.cpu.usage`)
315320
- `k8s.pod.cpu.utilization` (renamed to `k8s.pod.cpu.usage`)
316321
- `container.cpu.utilization` (renamed to `container.cpu.usage`)
317322

318323
The above metrics show usage counted in CPUs and it's not a percentage of used resources.
319324
These metrics were previously incorrectly named using the utilization term.
320325

326+
You can enable the usage of the deprecated metrics by disabling the `receiver.kubeletstats.enableCPUUsageMetrics` feature gate.
327+
321328
#### `receiver.kubeletstats.enableCPUUsageMetrics` feature gate
322329

323330
- alpha: when enabled it makes the `.cpu.usage` metrics enabled by default, disabling the `.cpu.utilization` metrics

receiver/kubeletstatsreceiver/documentation.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Total cumulative CPU time (sum of all cores) spent by the container/pod/node sin
2020
| ---- | ----------- | ---------- | ----------------------- | --------- |
2121
| s | Sum | Double | Cumulative | true |
2222
23-
### container.cpu.utilization
23+
### container.cpu.usage
2424
25-
Container CPU utilization
25+
Total CPU usage (sum of all cores per second) averaged over the sample window
2626
2727
| Unit | Metric Type | Value Type |
2828
| ---- | ----------- | ---------- |
29-
| 1 | Gauge | Double |
29+
| {cpu} | Gauge | Double |
3030
3131
### container.filesystem.available
3232
@@ -108,13 +108,13 @@ Total cumulative CPU time (sum of all cores) spent by the container/pod/node sin
108108
| ---- | ----------- | ---------- | ----------------------- | --------- |
109109
| s | Sum | Double | Cumulative | true |
110110
111-
### k8s.node.cpu.utilization
111+
### k8s.node.cpu.usage
112112
113-
Node CPU utilization
113+
Total CPU usage (sum of all cores per second) averaged over the sample window
114114
115115
| Unit | Metric Type | Value Type |
116116
| ---- | ----------- | ---------- |
117-
| 1 | Gauge | Double |
117+
| {cpu} | Gauge | Double |
118118
119119
### k8s.node.filesystem.available
120120
@@ -226,13 +226,13 @@ Total cumulative CPU time (sum of all cores) spent by the container/pod/node sin
226226
| ---- | ----------- | ---------- | ----------------------- | --------- |
227227
| s | Sum | Double | Cumulative | true |
228228
229-
### k8s.pod.cpu.utilization
229+
### k8s.pod.cpu.usage
230230
231-
Pod CPU utilization
231+
Total CPU usage (sum of all cores per second) averaged over the sample window
232232
233233
| Unit | Metric Type | Value Type |
234234
| ---- | ----------- | ---------- |
235-
| 1 | Gauge | Double |
235+
| {cpu} | Gauge | Double |
236236
237237
### k8s.pod.filesystem.available
238238
@@ -386,13 +386,13 @@ metrics:
386386
enabled: true
387387
```
388388
389-
### container.cpu.usage
389+
### container.cpu.utilization
390390
391-
Total CPU usage (sum of all cores per second) averaged over the sample window
391+
Container CPU utilization
392392
393393
| Unit | Metric Type | Value Type |
394394
| ---- | ----------- | ---------- |
395-
| {cpu} | Gauge | Double |
395+
| 1 | Gauge | Double |
396396
397397
### container.uptime
398398
@@ -450,13 +450,13 @@ Container memory utilization as a ratio of the container's requests
450450
| ---- | ----------- | ---------- |
451451
| 1 | Gauge | Double |
452452
453-
### k8s.node.cpu.usage
453+
### k8s.node.cpu.utilization
454454
455-
Total CPU usage (sum of all cores per second) averaged over the sample window
455+
Node CPU utilization
456456
457457
| Unit | Metric Type | Value Type |
458458
| ---- | ----------- | ---------- |
459-
| {cpu} | Gauge | Double |
459+
| 1 | Gauge | Double |
460460
461461
### k8s.node.uptime
462462
@@ -474,13 +474,13 @@ Pod cpu utilization as a ratio of the node's capacity
474474
| ---- | ----------- | ---------- |
475475
| 1 | Gauge | Double |
476476
477-
### k8s.pod.cpu.usage
477+
### k8s.pod.cpu.utilization
478478
479-
Total CPU usage (sum of all cores per second) averaged over the sample window
479+
Pod CPU utilization
480480
481481
| Unit | Metric Type | Value Type |
482482
| ---- | ----------- | ---------- |
483-
| {cpu} | Gauge | Double |
483+
| 1 | Gauge | Double |
484484
485485
### k8s.pod.cpu_limit_utilization
486486

receiver/kubeletstatsreceiver/factory.go

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const (
2525
enableCPUUsageMetricsFeatureFlag = "receiver.kubeletstats.enableCPUUsageMetrics"
2626
)
2727

28-
var enableCPUUsageMetrics = featuregate.GlobalRegistry().MustRegister(
28+
var EnableCPUUsageMetrics = featuregate.GlobalRegistry().MustRegister(
2929
enableCPUUsageMetricsFeatureFlag,
30-
featuregate.StageAlpha,
30+
featuregate.StageBeta,
3131
featuregate.WithRegisterDescription("When enabled the container.cpu.utilization, k8s.pod.cpu.utilization and k8s.node.cpu.utilization metrics will be replaced by the container.cpu.usage, k8s.pod.cpu.usage and k8s.node.cpu.usage"),
3232
featuregate.WithRegisterFromVersion("v0.110.0"),
3333
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/27885"),
@@ -78,31 +78,6 @@ func createMetricsReceiver(
7878
return nil, err
7979
}
8080

81-
if enableCPUUsageMetrics.IsEnabled() {
82-
if cfg.Metrics.ContainerCPUUtilization.Enabled {
83-
cfg.Metrics.ContainerCPUUtilization.Enabled = false
84-
cfg.Metrics.ContainerCPUUsage.Enabled = true
85-
}
86-
if cfg.Metrics.K8sPodCPUUtilization.Enabled {
87-
cfg.Metrics.K8sPodCPUUtilization.Enabled = false
88-
cfg.Metrics.K8sPodCPUUsage.Enabled = true
89-
}
90-
if cfg.Metrics.K8sNodeCPUUtilization.Enabled {
91-
cfg.Metrics.K8sNodeCPUUtilization.Enabled = false
92-
cfg.Metrics.K8sNodeCPUUsage.Enabled = true
93-
}
94-
} else {
95-
if cfg.Metrics.ContainerCPUUtilization.Enabled {
96-
set.Logger.Warn("The default metric container.cpu.utilization is being replaced by the container.cpu.usage metric. Switch now by enabling the receiver.kubeletstats.enableCPUUsageMetrics feature gate.")
97-
}
98-
if cfg.Metrics.K8sPodCPUUtilization.Enabled {
99-
set.Logger.Warn("The default metric k8s.pod.cpu.utilization is being replaced by the k8s.pod.cpu.usage metric. Switch now by enabling the receiver.kubeletstats.enableCPUUsageMetrics feature gate.")
100-
}
101-
if cfg.Metrics.K8sNodeCPUUtilization.Enabled {
102-
set.Logger.Warn("The default metric k8s.node.cpu.utilization is being replaced by the k8s.node.cpu.usage metric. Switch now by enabling the receiver.kubeletstats.enableCPUUsageMetrics feature gate.")
103-
}
104-
}
105-
10681
scrp, err := newKubeletScraper(rest, set, rOptions, cfg.MetricsBuilderConfig, cfg.NodeName)
10782
if err != nil {
10883
return nil, err

receiver/kubeletstatsreceiver/internal/metadata/generated_config.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/kubeletstatsreceiver/internal/metadata/generated_metrics.go

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/kubeletstatsreceiver/internal/metadata/generated_metrics_test.go

Lines changed: 3 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/kubeletstatsreceiver/metadata.yaml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,15 @@ attributes:
8282

8383
metrics:
8484
k8s.node.cpu.usage:
85-
enabled: false
85+
enabled: true
8686
description: "Total CPU usage (sum of all cores per second) averaged over the sample window"
8787
unit: "{cpu}"
8888
gauge:
8989
value_type: double
9090
attributes: []
9191
k8s.node.cpu.utilization:
92-
enabled: true
92+
enabled: false
9393
description: "Node CPU utilization"
94-
warnings:
95-
if_enabled: "This metric will be disabled in a future release. Use metric k8s.node.cpu.usage instead."
9694
unit: "1"
9795
gauge:
9896
value_type: double
@@ -197,17 +195,15 @@ metrics:
197195
aggregation_temporality: cumulative
198196
attributes: []
199197
k8s.pod.cpu.usage:
200-
enabled: false
198+
enabled: true
201199
description: "Total CPU usage (sum of all cores per second) averaged over the sample window"
202200
unit: "{cpu}"
203201
gauge:
204202
value_type: double
205203
attributes: [ ]
206204
k8s.pod.cpu.utilization:
207-
enabled: true
205+
enabled: false
208206
description: "Pod CPU utilization"
209-
warnings:
210-
if_enabled: "This metric will be disabled in a future release. Use metric k8s.pod.cpu.usage instead."
211207
unit: "1"
212208
gauge:
213209
value_type: double
@@ -354,17 +350,15 @@ metrics:
354350
aggregation_temporality: cumulative
355351
attributes: []
356352
container.cpu.usage:
357-
enabled: false
353+
enabled: true
358354
description: "Total CPU usage (sum of all cores per second) averaged over the sample window"
359355
unit: "{cpu}"
360356
gauge:
361357
value_type: double
362358
attributes: [ ]
363359
container.cpu.utilization:
364-
enabled: true
360+
enabled: false
365361
description: "Container CPU utilization"
366-
warnings:
367-
if_enabled: "This metric will be disabled in a future release. Use metric container.cpu.usage instead."
368362
unit: "1"
369363
gauge:
370364
value_type: double

0 commit comments

Comments
 (0)