Docker: 10-minute build container monitoring system Cadvisor+influxdb+grafana

Source: Internet
Author: User
Tags create database docker ps grafana docker run influxdb cadvisor

1. Concept

Cadvisor: For data acquisition
InfluxDB: For data storage
Grafana: For data presentation

1.1 Cadvisor

It is a monitoring tool that Google uses to monitor the resource information of a single node. Cadvisor provides a glance at a single node multi-container resource monitoring function. Google's kubernetes also by default as a single-node resource monitoring tool, the lack of provincial capital of each node is installed cadvisor. Summed up the main two points:

    • Show Host and container two levels of monitoring data.

    • Show historical change data.

? Because the cadvisor provides a slightly rudimentary interface, and it needs to jump between pages, and can only monitor a host, it can be challenging to question its usefulness. But one of the highlights of cadvisor is that it can export monitored data to third-party tools that are further processed by these tools.

? We can position cadvisor as a monitoring data collector , and collecting and exporting data is its strength, not the presentation of the data.

1.2 InfluxDB

InfluxDB is an open source distributed timing, event, and metrics database written in the go language without the need for external dependencies. Similar databases are elasticsearch, graphite and so on.

Influxdb Main Features

    • Support time-dependent related functions (such as maximum, minimum, sum, etc.) based on time series;
    • Measurable: You can calculate large amounts of data in real time;
    • Event-based: It supports arbitrary event data;

Influxdb Main Features

    • No structure (modeless): can be any number of columns;
    • can be expanded;
    • Support min, max, sum, count, mean, median a series of functions, convenient statistics;
    • Native HTTP support with built-in HTTP API;
    • Powerful class-SQL syntax;
    • Self-management interface, easy to use;
1.3 Grafana

Grafana is a visualization panel (Dashboard) with very beautiful charts and layouts, a full-featured metric panel and graphic editor that supports graphite, Zabbix, InfluxDB, Prometheus, and Opentsdb as data sources. Grafana Main Features: Flexible and rich graphical options, multiple styles can be mixed, day and night mode support, multiple data sources.

2. Deployment process
    • Create a custom Network Monitor (custom network name) for late containers to join this network, and of course you can ignore this step;
    • Create Influxdb container, create data user, database;
    • Create a cadvisor container;
    • Create Grafana container, configure Grafana;
3. Start Deployment 3.1 Create a custom network
[[email protected] ~]# docker network create monitorcc193568263604e3bc3e7a5d78f18d07af99810e1d5c19bac99fccfa045f48f5

To view the networks created:

3.2 Creating a Influxdb container
    • To start the container:

      [[email protected] ~]# docker run -d --name influxdb --net monitor -p 8083:8083 -p 8086:8086 tutum/influxdb
    • To see if it starts:

      [[email protected] ~]# docker ps -lCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                            NAMES30b9789e680d        tutum/influxdb      "/run.sh"           22 seconds ago      Up 21 seconds       0.0.0.0:8083->8083/tcp, 0.0.0.0:8086->8086/tcp   influxdb
    • Access Influxdb console, ip+8083 port access:

    • Create Cadvisor database, User:

      CREATE USER "root" with PASSWORD ' 123456 ' and all privileges

CREATE DATABASE "Cadvisor"

3.3 Creating a Cadvisor container
    • To run the Cadvisor container:

      $docker run -d --name=cadvisor --net monitor -p 8080:8080 --mount type=bind,src=/,dst=/rootfs,ro --mount type=bind,src=/var/run,dst=/var/run --mount type=bind,src=/sys,dst=/sys,ro --mount type=bind,src=/var/lib/docker/,dst=/var/lib/docker,ro google/cadvisor -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=influxdb:8086
    • View Cadvisor Containers:

      [[email protected] ~]# docker ps -lCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES90871ba5be7e        google/cadvisor     "/usr/bin/cadvisor -…"   51 seconds ago      Up 50 seconds       0.0.0.0:8080->8080/tcp   cadvisor
    • Test through ip+8080 port access:

      As can be seen, in fact, Cadvisor also has a basic graphical display function, we mainly use it to do data collection.
3.4 Creating a Granafa container
    • To run the Granafa container:

      [[email protected] ~]# docker run -d --name grafana --net monitor -p 3000:3000 grafana/grafana
    • To view the results of a run:

      [[email protected] ~]# docker ps -lCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMESa90e03e2017a        grafana/grafana     "/run.sh"           17 seconds ago      Up 16 seconds       0.0.0.0:3000->3000/tcp   grafana
    • Access Granfa, access via ip+3000 port, default account password (admin/admin):

    • Add a data source to the add datasource, such as:

    • Create new dashboard, such as:

    • After you've created a new monitoring item, come back home and find the project you just built:

Here Cadvisor+influxdb+grafana container Monitoring System on the deployment completed, as for other Grafana monitoring item configuration is not the focus of this article, if you are interested can refer to some official information or Baidu some information, are graphical interface operation, multi-point, more play , more than two to figure it out.

Docker: 10-minute build container monitoring system Cadvisor+influxdb+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.