Briefly, this error occurs when Elasticsearch tries to calculate the used swap space, but the total swap space is zero. This could be because the system doesn’t have a swap space configured or it’s disabled. To resolve this issue, you can either configure a swap space on your system or disable the swap check in Elasticsearch by setting the “bootstrap.memory_lock” to true in the Elasticsearch configuration file. Alternatively, you can disable swap space checks by setting “bootstrap.system_call_filter” to false.
This guide will help you check for common problems that cause the log ” cannot compute used swap when total swap is 0 and free swap is ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: monitor.
Log Context
Log “cannot compute used swap when total swap is 0 and free swap is ” classname is OsStats.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :
// as (total-free) and should report it as zero. // // We intentionally check for (total == 0) rather than (total - free total) which would be a different bug. if (free > 0) { logger.warn("cannot compute used swap when total swap is 0 and free swap is " + free); } return new ByteSizeValue(0); } return new ByteSizeValue(total - free); }