Home Explore Blog CI



kubernetes

5th chunk of `content/en/blog/_posts/2016-11-00-Kubernetes-Containers-Logging-Monitoring-With-Sematext.md`
1aa42a406cc1bdb0868ba5021da435699866e195f15e481d0000000100000596
![](https://lh5.googleusercontent.com/FUG46hzUj5FJSJgNLu4t6HIIa_QHcLXCDTgqHFoT711bO8M5BRd2w8hmzAk1ZQ0_iz7JkeDudoHNt50v_CaPWcanMOjSymiscMQZqBSudTZ4rrVDFWqkqtRNjOj9zrscQsrJ04Px) |
| Container Counters per Kubernetes Node over time |



Container Memory and Memory Fail Counters. These metrics are important to watch and very important to tune applications. Memory limits should fit the footprint of the deployed pod (application) to avoid situations where Kubernetes uses default limits (e.g. defined for a namespace), which could lead to OOM kills of containers. Memory fail counters reflect the number of failed memory allocations in a container, and in case of OOM kills a Docker Event is triggered. This event is then displayed in SPM because [Sematext Docker Agents](https://github.com/sematext/sematext-agent-docker) collects all Docker Events. The best practice is to tune memory setting in a few iterations:

- Monitor memory usage of the application container
- Set memory limits according to the observations
- Continue monitoring of memory, memory fail counters, and Out-Of-Memory events. If OOM events happen, the container memory limits may need to be increased, or debugging is required to find the reason for the high memory consumptions.

| ![](https://lh6.googleusercontent.com/Qq1_FhJRC72H0fvc71Oy_RqxbmBe8IZ4L4JTtADxBfLAjopRv2tJW5Fvc8DstD6iOj9JKfNt8U2gWAxzedx9tdnHuld-k1agDMAXDyWM-AuLOs7IDi-KNxEj_p-Kwef12SjeAiVc)

Title: Container Memory and Memory Fail Counters: Monitoring and Tuning
Summary
This section discusses the significance of monitoring Container Memory and Memory Fail Counters for Kubernetes applications. It emphasizes the importance of tuning application memory limits to avoid Kubernetes using default limits that could lead to Out-Of-Memory (OOM) kills. Memory fail counters indicate the number of failed memory allocations, and OOM kills trigger Docker Events, which are collected and displayed in SPM via Sematext Docker Agents. The best practice involves iteratively monitoring memory usage, setting appropriate limits, and continuously observing memory fail counters and OOM events. If OOM events occur, memory limits may need to be increased or debugging performed to identify the cause of high memory consumption. The provided image visually represents the container memory usage over time.