Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate memory.working_set.limit.pct for pod and container metricset #29547

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Preliminary AIX support {pull}27954[27954]
- Add option to skip older k8s events {pull}29396[29396]
- Add `add_resource_metadata` configuration to Kubernetes module. {pull}29133[29133]
- Add `memory.workingset.limit.pct` field in Kubernetes container/pod metricset. {pull}29547[29547]

*Packetbeat*

Expand Down
24 changes: 24 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41959,6 +41959,18 @@ format: bytes

--

*`kubernetes.container.memory.workingset.limit.pct`*::
+
--
Working set memory usage as a percentage of the defined limit for the container (or total node allocatable memory if unlimited)


type: scaled_float

format: percent

--

*`kubernetes.container.memory.pagefaults`*::
+
--
Expand Down Expand Up @@ -43023,6 +43035,18 @@ format: bytes

--

*`kubernetes.pod.memory.working_set.limit.pct`*::
+
--
Working set memory usage as a percentage of the defined limit for the pod containers (or total node allocatable memory if unlimited)


type: scaled_float

format: percent

--


*`kubernetes.pod.memory.rss.bytes`*::
+
Expand Down
5 changes: 5 additions & 0 deletions metricbeat/module/kubernetes/container/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@
format: bytes
description: >
Working set memory usage
- name: limit.pct
type: scaled_float
format: percent
description: >
Working set memory usage as a percentage of the defined limit for the container (or total node allocatable memory if unlimited)
- name: pagefaults
type: double
description: >
Expand Down
9 changes: 5 additions & 4 deletions metricbeat/module/kubernetes/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ func TestEventMapping(t *testing.T) {
"memory.majorpagefaults": 0,

// calculated pct fields:
"cpu.usage.node.pct": 0.005631997,
"cpu.usage.limit.pct": 0.005631997,
"memory.usage.node.pct": 0.01,
"memory.usage.limit.pct": 0.1,
"cpu.usage.node.pct": 0.005631997,
"cpu.usage.limit.pct": 0.005631997,
"memory.usage.node.pct": 0.01,
"memory.usage.limit.pct": 0.1,
"memory.workingset.limit.pct": 0.09943977591036414,

"name": "nginx",

Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/kubernetes/container/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common.

if memLimit > 0 {
containerEvent.Put("memory.usage.limit.pct", float64(container.Memory.UsageBytes)/memLimit)
containerEvent.Put("memory.workingset.limit.pct", float64(container.Memory.WorkingSetBytes)/memLimit)
}

events = append(events, containerEvent)
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kubernetes/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions metricbeat/module/kubernetes/pod/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
format: bytes
description: >
Total working set memory
- name: limit.pct
type: scaled_float
format: percent
description: >
Working set memory usage as a percentage of the defined limit for the pod containers (or total node allocatable memory if unlimited)
- name: rss
type: group
fields:
Expand Down
3 changes: 3 additions & 0 deletions metricbeat/module/kubernetes/pod/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common.
}
if memLimit > 0 {
podEvent.Put("memory.usage.limit.pct", float64(usageMem)/memLimit)
podEvent.Put("memory.working_set.limit.pct", float64(workingSet)/memLimit)
MichaelKatsoulis marked this conversation as resolved.
Show resolved Hide resolved

}
}

Expand All @@ -137,6 +139,7 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common.
}
if memLimit > 0 {
podEvent.Put("memory.usage.limit.pct", float64(workingSet)/memLimit)
podEvent.Put("memory.working_set.limit.pct", float64(workingSet)/memLimit)
}
}

Expand Down
7 changes: 4 additions & 3 deletions metricbeat/module/kubernetes/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ func TestEventMapping(t *testing.T) {
"cpu.usage.node.pct": 0.005631997,
"cpu.usage.limit.pct": 0.005631997,

"memory.usage.bytes": 1462272,
"memory.usage.node.pct": 0.01,
"memory.usage.limit.pct": 0.1,
"memory.usage.bytes": 1462272,
"memory.usage.node.pct": 0.01,
"memory.usage.limit.pct": 0.1,
"memory.working_set.limit.pct": 0.09943977591036414,
}

for k, v := range testCases {
Expand Down