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

cgroups2: export memory max usage and swap max usage #305

Merged
merged 1 commit into from
Nov 29, 2023
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
2 changes: 2 additions & 0 deletions cgroup2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,10 @@ func (c *Manager) Stat() (*stats.Metrics, error) {
ThpCollapseAlloc: out["thp_collapse_alloc"],
Usage: getStatFileContentUint64(filepath.Join(c.path, "memory.current")),
UsageLimit: getStatFileContentUint64(filepath.Join(c.path, "memory.max")),
MaxUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.peak")),
SwapUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.current")),
SwapLimit: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.max")),
SwapMaxUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.peak")),
}
if len(memoryEvents) > 0 {
metrics.MemoryEvents = &stats.MemoryEvents{
Expand Down
110 changes: 65 additions & 45 deletions cgroup2/stats/metrics.pb.go

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

14 changes: 14 additions & 0 deletions cgroup2/stats/metrics.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ file {
type: TYPE_UINT64
json_name: "swapLimit"
}
field {
name: "max_usage"
number: 36
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "maxUsage"
}
field {
name: "swap_max_usage"
number: 37
label: LABEL_OPTIONAL
type: TYPE_UINT64
json_name: "swapMaxUsage"
}
}
message_type {
name: "MemoryEvents"
Expand Down
2 changes: 2 additions & 0 deletions cgroup2/stats/metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ message MemoryStat {
uint64 usage_limit = 33;
uint64 swap_usage = 34;
uint64 swap_limit = 35;
uint64 max_usage = 36;
uint64 swap_max_usage = 37;
}

message MemoryEvents {
Expand Down