Categories
Self-Hosting

Docker container monitoring with Netdata

This blog is contributed to Developer Nation by Netdata

Properly monitoring the health and performance of Docker containers is an essential skill for solo developers and large teams alike. As your infrastructure grows in complexity, it’s important to streamline every facet of the performance of your apps/services. Plus, it’s essential that the tools you use to make those performance decisions work across teams, and allow for complex scaling architectures.

Netdata does all that, and thanks to our Docker container collector, you can now monitor the health and performance of your Docker containers in real-time.

With Docker container monitoring enabled via cgroups, you get real-time, interactive charts showing key CPU, memory, disk I/O, and networking of entire containers. Plus, you can use other collectors to monitor the specific applications or services running inside Docker containers.

With these per-second metrics at your fingertips, you can get instant notifications about outages, performance hiccups, or excessive resource usage, visually identify the anomaly, and fix the root cause faster.

What is Docker?

Docker is a virtualization platform that helps developers deploy their software in reproducible and isolated packages called containers. These containers have everything the software needs to run properly, including libraries, tools, and their application’s source code or binaries. And because these packages contain everything the application needs, it runs everywhere, isolating problems where code works in testing, but not production.

Docker containers are a popular platform for distributing software via Docker Hub, as we do for Netdata itself. But perhaps more importantly, containers are now being “orchestrated” with programs like Docker Compose, and platforms like Kubernetes and Docker Swarm. DevOps teams also use containers to orchestrate their microservices architectures, making them a fundamental component of scalable deployments.

How Netdata monitors Docker containers

Netdata uses control groups—most often referred to as cgroups—to monitor Docker containers. cgroups is a Linux kernel feature that limits and tracks the resource usage of a collection of processes. When you combine resource limits with process isolation (thanks, namespaces!), you get what we commonly refer to as containers.

Linux uses virtual files, usually placed at /sys/fs/cgroup/, to report the existing containers and their resource usage. Netdata scans these files/directories every few seconds (configurable via check for new cgroups every in netdata.conf) to find added or removed cgroups.

The best part about monitoring Docker containers with Netdata is that it’s zero-configuration. If you have Docker containers running when you install Netdata, it’ll auto-detect them and start monitoring their metrics. If you spin up Docker containers after installing Netdata, restart it with sudo service netdata restart or the appropriate variant for your system, and you’ll be up and running!

Read more about Netdata’s cgroup collector in our documentation.

View many containers at-a-glance

Netdata auto-detects running containers and auto-populates the right-hand menu with their IDs or container names, based on the configuration of your system. This interface is expandable to any number of Docker containers you want to monitor with Netdata, whether it’s 1, 100, or 1,000.

Netdata also uses its meaningful presentation to organize CPU and memory charts into families, so you can quickly understand which containers are using the most CPU, memory, disk I/O, or networking, and begin correlating that with other metrics from your system.

Get alarms when containers go awry

Netdata comes with pre-configured CPU and memory alarms for every running Docker container. Once Netdata auto-detects a Docker container, it initializes three alarms: RAM usage, RAM+swap usage, and CPU utilization for the cgroup. These alarms calculate their usage based on the cgroup limits you set, so they’re completely dynamic to any Docker setup.

You can, of course, edit your health.d/cgroups.conf file to modify the existing alarms or create new ones entirely.

Dive into real-time metrics for containerized apps and services

Netdata’s Docker monitoring doesn’t stop with entire containers—it’s also fully capable of monitoring the apps/services running inside those containers. This way, you’ll get more precise metrics for your mission-critical web servers or databases, plus all the pre-configured alarms that come with that collector!

You can monitor specific metrics for any of the 200+ apps/services like MySQL, Nginx, or Postgres, with little or no configuration on your part. Just set the service up using the recommended method, and Netdata will auto-detect it.

For example, here are some real-time charts for an Nginx web server, running inside of a Docker container, while it’s undergoing a stress test.

Visit our documentation and use the search bar at the top to figure out how to monitor favorite containerized service.

What’s next?

To get started monitoring Docker containers with Netdata, install Netdata on any system running the Docker daemon. Netdata will auto-detect your cgroups and begin monitoring the health and performance of any running Docker containers.

If you already have Netdata installed and want to enable Docker monitoring, restart Netdata using the appropriate command for your system.

Netdata handles ephemeral Docker containers without complaint, so don’t worry about situations where you’re scaling up and down on any given system. As soon as a new container is running, Netdata dynamically attaches all the relevant alarms, and you can see new charts after refreshing the dashboard.

For a more thorough investigation of Netdata’s Docker monitoring capabilities, read our cgroups collector documentation and our Docker Engine documentation. You can also learn about running Netdata inside of a container in your ongoing efforts to containerize everything.

Categories
Tips

7 DevOps books to read in 2021

If you are looking to learn more about Ansible, Azure, Docker, Terraform, Kubernetes, and their roles in DevOps, then this blog post is for you. We continue our series of must-read books with 7 DevOps books to read in 2021, as recommended by our friends at Packt.

Azure DevOps Explained

Get started with Azure DevOps and develop your DevOps practices

What reviews say:

” In my opinion, it is definitely one of the greatest books I ever read for DevOps.
Although I am Azure DevOps certified, I really enjoy reading this book and it gives me an extra overview of what I have learned.
It is well structured and the fact that is simple to read and follow along makes it more attractive. “

Terraform Cookbook

Efficiently define, launch, and manage Infrastructure as Code across various cloud platforms

What reviews say:

” I had the chance to read this book and I was really pleased by its content.
noting that this is not the first book or terraform material that I read, I would say that this book contains valuable structured information with also access to code used in various chapters.
it is certainly an asset for those starting their journey with terraform.”

Practical Ansible 2

Automate infrastructure, manage configuration, and deploy applications with Ansible 2.9

What reviews say:

This book is probably perfect for someone with reasonable experience. It was what I needed as a second book to get a good look at the ecosystem and a second opinion of how to use it. “

Kubernetes – A Complete DevOps Cookbook

Build and manage your applications, orchestrate containers, and deploy cloud-native services

What reviews say:

” Great coverage of common Kubernetes and DevOps tools. I’ve learned about some of the tools I haven’t used before like Jenkins X, GitLab, Fossa, Trivy, Litmus Chaos etc.
Although some of the long YAML files are provided in the GitHub repository I got the digital version, makes it easier to copy paste. “

Kubernetes and Docker – An Enterprise Guide

Effectively containerize applications, integrate enterprise systems, and scale applications in your enterprise

What reviews say:

“If you have worked on Kubernetes at all, you have experienced the frustration of trying to go beyond a cluster that has a single config file and a simple layer 7 load-balancer using NGINX. This book does truly target not only the enterprise user, but any person that wants to learn topics that make Kubernetes a complete offering.

I have been looking into the external-dns project on my list for a few months, but I never got around to doing much – Much to my surprise, when I was reading the topics covered in the book, it mentioned Services and external-dns. Chapter 6, alone, to me is one reason to buy the book since it explained and showed me how to install Metallb with external-dns in easy to understand terms and hands-on configuration.”

Learning DevOps

The complete guide to accelerate collaboration with Jenkins, Kubernetes, Terraform and Azure DevOps

” I would suggest reading through each section before you work along with the steps. There’s lots of references to other resources that are not necessarily part of the topics being discussed ”

Docker for Developers

Develop and run your application with Docker containers using DevOps tools for continuous delivery

” When reading articles, tutorials and even books, that is very common that at the end of the reading you struggle about how to translate that to a real production situation. Believe me, this book is different. You get to the end with a sense that you are very likely to know what are the next steps to apply what you learned to your existent or new projects. And this means a lot. The book has some great balance from history, concepts, example and practice. ”

What books have helped you deepen your knowledge of DevOps? Do share in the comments. Looking for more books to read? We have also shared recommended Backend and Frontend books.