runc icon indicating copy to clipboard operation
runc copied to clipboard

libcontainer: include cgroupv2 memory.events in Manager.GetStats

Open phanhuyn opened this issue 2 years ago • 3 comments

Changes

  • This PR reads from memory.events and adds the values to the returned struct Stats.MemoryStats in Manager.GetStats

  • In cgroup v2, memory.events includes some useful metrics on memory throttle and oom kill on the cgroup.

Why

  • Original use case is for cadvisor to expose those values as Prometheus metrics. (cadvisor uses runc libcontainer to read some cgroup stats)
  • The cadvisor code change (not merged, just demo the idea)

Others

  • The change adds on additional file read to Manager.GetStats
  • The purpose of the change is to allow the user of runc as a library (e.g. cadvisor) to read memory.events, not to modify current behavior. I was considering adding the code to a separate methods MemoryEvents instead of modifying the original GetStats. I'm not too sure which one fits better with the code design, let me know your feedback.

Signed-off-by: Nguyen Phan Huy [email protected]

phanhuyn avatar Sep 20 '22 10:09 phanhuyn

Hi @kolyshkin, could you help to see if this feature could be added to runc's libcontainer? (I am not sure who to reach out to ask, I saw you're active on the recent MRs)

phanhuyn avatar Sep 29 '22 07:09 phanhuyn

May I carry the rest of the work? I think it just remain some test task

Zheaoli avatar Nov 12 '23 05:11 Zheaoli

May I carry the rest of the work? I think it just remain some test task

Sure! Thank you

phanhuyn avatar Nov 13 '23 22:11 phanhuyn