Skip to content

Commit 1fe8fdf

Browse files
authored
Add pod metrics (#23844)
**Description:** Add explicitly `k8s.node.allocatable_pods` to the list of Kubernetes node metrics available, which went missing during the pdata translation **Link to tracking Issue:** #23839
1 parent 377f666 commit 1fe8fdf

File tree

10 files changed

+125
-0
lines changed

10 files changed

+125
-0
lines changed

.chloggen/add-back-pods-metrics.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use this changelog template to create an entry for release notes.
2+
# If your change doesn't affect end users, such as a test fix or a tooling change,
3+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
4+
5+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
6+
change_type: bug_fix
7+
8+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
9+
component: k8sclusterreceiver
10+
11+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
12+
note: Add explicitly `k8s.node.allocatable_pods` to the list of Kubernetes node metrics available, which went missing during the pdata translation
13+
14+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
15+
issues: [23839]
16+
17+
# (Optional) One or more lines of additional information to render under the primary note.
18+
# These lines will be padded with 2 spaces and then inserted directly into the document.
19+
# Use pipe (|) for multiline entries.
20+
subtext:

receiver/k8sclusterreceiver/internal/node/documentation.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ How many bytes of RAM memory remaining that the node can allocate to pods
3838
| ---- | ----------- | ---------- |
3939
| By | Gauge | Int |
4040
41+
### k8s.node.allocatable_pods
42+
43+
How many pods remaining the node can allocate
44+
45+
| Unit | Metric Type | Value Type |
46+
| ---- | ----------- | ---------- |
47+
| {pods} | Gauge | Int |
48+
4149
### k8s.node.allocatable_storage
4250
4351
How many bytes of storage remaining that the node can allocate to pods

receiver/k8sclusterreceiver/internal/node/internal/metadata/generated_config.go

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

receiver/k8sclusterreceiver/internal/node/internal/metadata/generated_config_test.go

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

receiver/k8sclusterreceiver/internal/node/internal/metadata/generated_metrics.go

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

receiver/k8sclusterreceiver/internal/node/internal/metadata/generated_metrics_test.go

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

receiver/k8sclusterreceiver/internal/node/internal/metadata/testdata/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ all_set:
77
enabled: true
88
k8s.node.allocatable_memory:
99
enabled: true
10+
k8s.node.allocatable_pods:
11+
enabled: true
1012
k8s.node.allocatable_storage:
1113
enabled: true
1214
k8s.node.condition_disk_pressure:
@@ -34,6 +36,8 @@ none_set:
3436
enabled: false
3537
k8s.node.allocatable_memory:
3638
enabled: false
39+
k8s.node.allocatable_pods:
40+
enabled: false
3741
k8s.node.allocatable_storage:
3842
enabled: false
3943
k8s.node.condition_disk_pressure:

receiver/k8sclusterreceiver/internal/node/metadata.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,11 @@ metrics:
7373
enabled: true
7474
description: How many bytes of storage remaining that the node can allocate to pods
7575
unit: "By"
76+
gauge:
77+
value_type: int
78+
k8s.node.allocatable_pods:
79+
enabled: true
80+
description: How many pods remaining the node can allocate
81+
unit: "{pods}"
7682
gauge:
7783
value_type: int

receiver/k8sclusterreceiver/internal/node/nodes.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ func GetMetrics(set receiver.CreateSettings, node *corev1.Node, nodeConditionTyp
8686
mb.RecordK8sNodeAllocatableEphemeralStorageDataPoint(ts, quantity.Value())
8787
case corev1.ResourceStorage:
8888
mb.RecordK8sNodeAllocatableStorageDataPoint(ts, quantity.Value())
89+
case corev1.ResourcePods:
90+
mb.RecordK8sNodeAllocatablePodsDataPoint(ts, quantity.Value())
8991
default:
9092
set.Logger.Warn("unknown node condition type", zap.Any("conditionType", v1NodeAllocatableTypeValue))
9193
}

receiver/k8sclusterreceiver/internal/node/testdata/expected.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ resourceMetrics:
3131
- asInt: "456"
3232
name: k8s.node.allocatable_memory
3333
unit: By
34+
- description: How many pods remaining the node can allocate
35+
gauge:
36+
dataPoints:
37+
- asInt: "12"
38+
name: k8s.node.allocatable_pods
39+
unit: "{pods}"
3440
- description: Whether this node is DiskPressure (1), not DiskPressure (0) or in an unknown state (-1)
3541
gauge:
3642
dataPoints:

0 commit comments

Comments
 (0)