Directory
Directory document source Docker monitoring introduction Docker monitoring components Docker monitoring installation and configuration
Document Source document Source: How to setup Docker monitoring by Garyond translation, correction and collation Docker monitoring Introduction
We provide more and more Docker hosts and containers, and it is increasingly necessary to monitor Docker servers and containers. This article will guide you through the configuration and collaboration of multiple different components to achieve Docker monitoring. Docker Monitoring Components
First, let's assume that Docker Engine is installed, configured, and running on your host. Make sure that you can connect to the Docker host locally or over a network IP through a Web browser. Below we will detail how to create our Docker monitoring program. cadvisor: Google's Open-source tool for monitoring infrastructure applications is a powerful monitoring tool that can monitor Docker containers by running containers on Docker hosts without any configuration, and can monitor Docker hosts. For more detailed operations and configuration options, you can view the Cadvisor project documentation on GitHub. influxdb: It is a distributed time series database. Cadvisor only displays real-time information, but does not store monitoring data. Therefore, we need to provide a sequential database for storing the monitoring information provided by the Cadvisor component to display time series data in addition to real-time information. Grafana: The Grafana visual display platform allows us to visually display monitoring information. It allows us to query the influxdb and visualize it through powerful charting capabilities.
This article configures the component version information as follows:
-Influxdb: v 1.0.0
-cadvisior:v 0.24.1
-Grafana: v 4.0.2
Docker monitoring installation and configuration
Below, we will be based on the above Docker monitoring components for installation and configuration, the formation of a unified Docker monitoring platform.
We will first install influxdb so that it can collaborate with Cadvisor.
1. Install Influxdb
Download Influxdb Mirrors
Docker Pull Tutum/influxdb
running the Influxdb container
Docker run-d \
p 8083:8083 \
p 8086:8086 \--expose 8090
\--expose
8099 \
--name influxsrv \
t Utum/influxdb
After successful operation of the Influxdb container, access to http://docker-host-ip:8083 access Influxdb Admin via a Web browser and login to the background management system (default username: root, default password: root).
2. Create cadvisor application Database
After logging into the INFLUXDB background database management platform, create a cadvisor database for storing real-time monitoring data obtained by cadvisor applications. Create the database and user in the Querie s input box in the INFLUXDB Admin interface:
# CREATE DATABASE
' cadvisor ';
# Create user
' Cadvisor ' with PASSWORD ' cadvisor '
# User authorized Grant all
privileges on ' cadvisor ' to ' cadvisor '
# Grant Write permission Grant
write on ' cadvisor ' to ' cadvisor '
grant READ on ' cadvisor ' to ' cadvisor '
3. Run the Cadvisor application container and interconnect with the INFLUXDB container
Start Cadvisor Container
Docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
Volume=/var/lib/docker/:/var/lib/docker:ro \
P 8080:8080 \
--detach=true \
--link influxsrv: INFLUXSRV \
--name=cadvisor \
google/cadvisor:latest \
-storage_driver=influxdb \
-storage_ Driver_db=cadvisor \
-storage_driver_host=influxsrv:8086
After the Cadvisor application container starts successfully, access to address http://docker-host-ip:8080 through a Web browser allows you to view the Docker host and container resource statistics that the CADVISOR monitoring tool collects.
4. Run Grafana visualization platform and interconnect with INFLUXDB container
Docker run-d \
P 3000:3000 \
e influxdb_host=localhost \
e influxdb_port=8086 \
e influxdb_name= Cadvisor \
e influxdb_user=root \
e influxdb_pass=root \
--link influxsrv:influxsrv \
--name Grafana \
Grafana/grafana
5. Login Grafana Management Platform
Access the address http://docker-host-ip:3000 through a Web browser Grafana management platform. User name: admin Password: admin
6. Configure Grafana and INFLUXDB database connections
(1). Configure Granfana Data source
In the Grafana management platform, click Add Data Source to configure the data source. As shown in the following figure.
Basic information
Name:influxdb
Type:influxdb
default:checked Http Settings
url:http://influxsrv:8086
Access:proxy HTTP Auth
Basic auth:checked Basic Auth Details
User:admin
Password:admin Influxdb Details
Database:cadvisor
User:cadvisor
Password:cadvisor
After the configuration is complete, we have established a connection with INFLUXDB, and we will test it below.
(2). Add Dashboard
Below we will use Grafana to configure our first dashboard and visualize the monitoring data from Cadvisor.
1. Click on "Grafana" icon, open the Dashboard menu, choose New Dashboard;
2. Select the appropriate component in the dashboard panel and drag to the relevant location;
3. Click on the title of the panel, will pop up the corresponding options "View", "edit", "duplicates", "share" and remove the button;
4. Select the "edit" option, the corresponding configuration items appear, in the "Metrics" tab to configure the corresponding data table and data source information;
For example: Configuring Memory usage information
In the Metric tab, the Configuration data table source is: SELECT mean ("value") from "Memory_usage" WHERE $timeFilter GROUP by Time (10s) fill (0), configure Data source panel Da Tasource is: cadvisor;
Configure the associated display units in the Axes tab.
5. After configuring the relevant options, click on the dashboard navigation bar Save button, you can complete the dashboard configuration.
At this point, all the configuration steps are complete and we can see the Grafana display the relevant monitoring chart information.