Skip to content

[Metricbeat] Zswap Metrics #47605

@b-deam

Description

@b-deam

Describe the enhancement:

Zswap is a lightweight compressed cache for swap pages. It takes pages that are in the process of being swapped out and attempts to compress them into a dynamically allocated RAM-based memory pool. zswap basically trades CPU cycles for potentially reduced swap I/O.

We should support capturing metrics around its usage.

When this kernel feature is available, host level metrics are available in /proc/meminfo, /proc/vmstat, and more detailed metrics are available in under /sys/kernel/debug/zswap:

$ sudo grep . -r /sys/kernel/debug/zswap
/sys/kernel/debug/zswap/stored_pages:1109442
/sys/kernel/debug/zswap/pool_total_size:3095379968
/sys/kernel/debug/zswap/written_back_pages:2489374
/sys/kernel/debug/zswap/reject_compress_poor:1271198
/sys/kernel/debug/zswap/reject_compress_fail:5531019
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:26833
/sys/kernel/debug/zswap/pool_limit_hit:8353

/proc/vmstat zswap metrics are already collected by the linux.memory dataset at the host level:

linux.memory.vmstat.zswpin
linux.memory.vmstat.zswpout 
linux.memory.vmstat.zswpwb

$ grep -i zswp /proc/vmstat
zswpin 13855559
zswpout 18028871
zswpwb 2489410

The /proc/meminfo zswap entries are ignored by the existing modules:

$ grep -i "zswap" /proc/meminfo
/proc/meminfo:Zswap:           3022844 kB
/proc/meminfo:Zswapped:        4437792 kB

Per-cgroupv2 zswap metrics are not currently collected by any module, but are available in the respective cgroup's memory.stat file:

$ grep -i zswp /sys/fs/cgroup/system.slice/docker-286485ddfe58bebb737cc5c8e244979fd312895627aad596e9ca79bb86278101.scope/memory.stat
zswpin 63851
zswpout 397089
zswpwb 1290

Describe a specific use case for the enhancement or feature:

We should support collecting metrics to allow for full monitoring of systems with Zswap enabled.

Host level sources:

/proc/meminfo 
/proc/vmstat
/sys/kernel/debug/zswap

Cgroup v2 level sources:

/sys/fs/cgroup/*/memory.stat

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions