I have a Kubernetes pod which shuts down and restarts itself because it went out of memory. There are multiple child processes which run asynchronously and use memory. I want each of them to log how much memory is available/used on the Kubernetes pod. The logs should be with the other Node js logs.
I know of process.memoryUsage()
, os.totalmem()
, os.freemem()
Which provide the following output respectively
{"ts":"2021-04-21T10:52:50.299Z","msg":"Node Memory Stats:{\"rss\":125792256,\"heapTotal\":94720000,\"heapUsed\":48927816,\"external\":1668086}","logger":"___","level":"info"}
{"ts":"2021-04-21T10:52:50.300Z","msg":"OS/POD Total Memory:17179869184, OS/POD Free memory:87195648","logger":"___","level":"info"}
I was wondering if there is any way I could do a system call to the pod, get its resources, and log in Node?