Configuring Docker monitoring with Influxdb+cadvisor+grafana

Source: Internet
Author: User
Tags auth memory usage grafana docker run influxdb cadvisor

Document Source
    • Document Source: How to setup Docker monitoring
    • Translation, correction and collation by Garyond
Introduction to Docker Monitoring

More and more Docker hosts and containers are available, and it is increasingly necessary to monitor Docker servers and containers. This article will guide you through the configuration and collaboration of several different components to implement Docker monitoring.

Docker Monitoring components

First, let's assume that you have installed, configured, and run the Docker engine on your console. Make sure that you can connect to the Docker host locally or over a network IP via a Web browser. Below we will describe in detail how to create our Docker monitoring solution.

    • cadvisor: Google Open source, a tool for monitoring infrastructure applications, is a powerful monitoring tool that can monitor Docker containers through containers running 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 time series database to store the monitoring information provided by the Cadvisor component in order to display timing data in addition to live information.
    • Grafana: The Grafana visual display platform allows us to visualize monitoring information. It allows us to query the influxdb and visualize it with 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 install and configure the Docker monitoring components as described above to form a unified Docker monitoring platform.

We will first install influxdb so that it can collaborate with Cadvisor.

1. Installing Influxdb

Download Influxdb image

docker pull tutum/influxdb

Running the INFLUXDB container

docker run -d    -p 8083:8083    -p 8086:8086    --expose 8090    --expose 8099    --name influxsrv    tutum/influxdb

After the Influxdb container runs successfully, access to INFLUXDB background management is accessed through a Web browser http://docker-host-ip:8083 and logged into the backend management system ( 默认用户名:root, 默认密码:root ).

Influxdb_connection_settings

2. Create a Cadvisor application database

After logging in to the INFLUXDB background database management platform, create a cAdvisor database for storing real-time monitoring data obtained by the Cadvisor application. Create the database and user in the Querie s input box in the INFLUXDB Admin interface:

Create_database
# 创建数据库create database ‘cadvisor‘; # 创建用户CREATE USER ‘cadvisor‘ WITH PASSWORD ‘cadvisor‘# 用户授权grant all privileges on ‘cadvisor‘ to ‘cadvisor‘# 授予读写权限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 the 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      

Cadvisor the application container starts successfully, the address is accessed through a Web browser to http://docker-host-ip:8080 view the resource statistics for the Docker hosts and containers collected by the CADVISOR monitoring tool.

Cadvisor WebUI

4. Run the Grafana visualization platform and interconnect with the 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 to Grafana management platform

Access the address via the Web browser to login to the http://docker-host-ip:3000 Grafana management platform.

    • User name: admin
    • Password: admin
Grafana_login

6. Configuring Grafana and Influxdb database connections

(1). Configuring the Granfana Data source

In the Grafana management platform, click Add Data Source to configure the data source. As shown in.

Add_datasource
    • 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 to the 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 the "Grafana" icon to open the Dashboard menu and select New Dashboard;

New Dashboard

2). Select the appropriate component in the dashboard panel and drag it to the relevant position;

Add_component

3). Click on the title of the panel and the corresponding option "View", "edit", "duplicates", "Share" and delete button will be displayed.

Edit Component

4). Select the "edit" option, the corresponding configuration item appears, and the corresponding data table and data source information are configured in the "Metrics" tab;

Edit_configure

Example: Configuring Memory usage information

Edit Memory Usage

In the Metric tab, configure the data table from the source: SELECT mean("value") FROM "memory_usage" WHERE $timeFilter GROUP BY time(10s) fill(0) , configure the data source panel datasource as: cadvisor ;

Configure the relevant display units in the Axes tab.

Config axies

5). After configuring the relevant options, click the Save button in the dashboard navigation bar to complete the dashboard configuration.

Save Config

Now that all the configuration steps are complete, we can see the Grafana display related monitoring chart information.



Garyond
Links: https://www.jianshu.com/p/d078d353d12f
Source: Pinterest
The copyright of the book is owned by the author, and any form of reprint should be contacted by the author for authorization and attribution.

(go) Configure Docker monitoring with Influxdb+cadvisor+grafana

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.