Book Image

Monitoring Docker

By : Russ McKendrick
Book Image

Monitoring Docker

By: Russ McKendrick

Overview of this book

This book will show you how monitoring containers and keeping a keen eye on the working of applications helps improve the overall performance of the applications that run on Docker. With the increased adoption of Docker containers, the need to monitor which containers are running, what resources they are consuming, and how these factors affect the overall performance of the system has become the need of the moment. This book covers monitoring containers using Docker's native monitoring functions, various plugins, as well as third-party tools that help in monitoring. Well start with how to obtain detailed stats for active containers, resources consumed, and container behavior. We also show you how to use these stats to improve the overall performance of the system. Next, you will learn how to use SysDig to both view your containers performance metrics in real time and record sessions to query later. By the end of this book, you will have a complete knowledge of how to implement monitoring for your containerized applications and make the most of the metrics you are collecting
Table of Contents (15 chapters)
Monitoring Docker
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

With the increase in the adoption of Docker containers, the need to monitor which containers are running, what resources they are consuming, and how it affects the overall performance of the system, has become a time-related need. Monitoring Docker will teach you how monitoring containers and keeping a keen eye on the working of applications help to improve the overall performance of the applications that run on Docker.

This book will cover monitoring containers using Docker's native monitoring functions, various plugins, and also third-party tools that help in monitoring. The book will first cover how to obtain detailed stats for the active containers, resources consumed, and container behavior. This book will also show the readers how to use these stats to improve the overall performance of the system.

What this book covers

Chapter 1, Introduction to Docker Monitoring, discusses how different it is to monitor containers compared to more traditional servers such as virtual machines, bare metal machines, and cloud instances (Pets versus Cattle and Chickens versus Snowflakes). This chapter also details the operating systems covered in the examples later in this book and also gives a little information on how to get a local test environment up and running using vagrant, so that installation instructions and practical examples can be easily followed.

Chapter 2, Using the Built-in Tools, helps you learn about the basic metrics you can get out of the vanilla Docker installation and how you can use them. Also, we will understand how to get real-time statistics on our running containers, how to use commands that are familiar to us, and how to get information on the processes that are launched as part of each container.

Chapter 3, Advanced Container Resource Analysis, introduces cAdvisor from Google, which adds a lot more precision to the basic tools provided by Docker. You will also learn how to install cAdvisor and start collecting metrics.

Chapter 4, A Traditional Approach to Monitoring Containers, looks at a traditional tool for monitoring services. By the end of this chapter, you should know your way around Zabbix and the various ways you can monitor your containers.

Chapter 5, Querying with Sysdig, describes Sysdig as "an open source, system-level exploration tool to capture system state and activity from a running Linux instance, then save, filter, and analyze it." In this chapter, you will learn how to use Sysdig to both view your containers' performance metrics in real time and also record sessions to query later.

Chapter 6, Exploring Third Party Options, walks you through a few of the Software as a Service (SaaS) options that are available, why you would use them, and how to install their clients on the host server.

Chapter 7, Collecting Application Logs from within the Container, looks at how we can get the content of the log files for the applications running within our containers to a central location so that they are available even if you have to destroy and replace a container.

Chapter 8, What Are the Next Steps?, looks at the next steps you can take in monitoring your containers by talking about the benefits of adding alerting to your monitoring. Also, we will cover some different scenarios and look at which type of monitoring is appropriate for each of them.

What you need for this book

To ensure the experience is as consistent as possible, we will be installing vagrant and VirtualBox to run the virtual machine that will act as a host to run our containers. Vagrant is available for Linux, OS X, and Windows; for details on how to install this, see the vagrant website at https://www.vagrantup.com/. The details of how to download and install VirtualBox can be found at https://www.virtualbox.org/; again, VirtualBox can be installed on Linux, OS X, and Windows.

Who this book is for

This book is for DevOps engineers and system administrators who want to manage Docker containers, better manage these containers using expert techniques and methods, and better maintain applications built on Docker.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

{
  "fields": {
    "@timestamp": [
      1444567706641
    ]
  },
  "sort": [
    1444567706641
  ]
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

{
  "fields": {
    "@timestamp": [
      1444567706641
    ]
  },
  "sort": [
    1444567706641
  ]
}

Any command-line input or output is written as follows:

cd ~/Documents/Projects/monitoring-docker/vagrant-ubuntu
vagrant up

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: http://www.packtpub.com/sites/default/files/downloads/Monitoring_Docker_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.