-
Problem report
-
Resolution: Unresolved
-
Trivial
-
None
-
7.2.6
-
None
-
Docker Hosted on Ubuntu 22 monitored by zabbix agent 2 using ootb template.
Steps to reproduce:
- Assign the docker template to a linux docker host
- The "Memory Usage" container item includes inactive file memory which is not indicative of actual reserved memory usage. Confusing for users who see 8 GB in zabbix, but 2 GB in "docker stats".
Result:
The "Memory Usage" container stat is not useful for analyzing or monitoring container health or host impact. Has some use cases for reviewing "freed" memory of a container and debugging, but not dashboarding or alerts.
Expected:
Similar to the calculation done by the docker stats functions (https://github.com/docker/cli/blob/58d318b99030aebd1c946653165fbfd492b47b09/cli/command/container/stats_helpers.go#L227) total_inactive_file or inactive_file should be subtracted from memory.usage in order to report real reserved memory.
In my case I did the following in the docker template:
- Change "Container {#NAME}: Get stats: Container {#NAME}: Memory usage" to "Container {#NAME}: Get stats: Container {#NAME}: Memory usage (raw)"
- Add a new stats-dependent item for "Container {#NAME}: Get stats: Container {#NAME}: Memory inactive file"
- Item Preprocessing:
- Replace "total_inactive_file" with "inactive_file" to be compatible with cgroup1 and cgroup2 stats.
- JSONPath "$.memory_stats.stats.inactive_file"
- Item Preprocessing:
- Add a new calculated item "Container {#NAME}: Memory usage"
Formula "last(//docker.container_stats.memory.usage"{#NAME}")-last(//docker.container_stats.memory.inactive_file"{#NAME}")"
On Windows the user should just be using the PrivateWorkingSet attribute for usage (which is not applicable to unix hosts). So maybe the formula should use PrivateWorkingSet if it's not zero, otherwise the calculation mentioned above? Haven't tested docker-on-windows monitoring.