Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of the construction of visual monitoring center for Docker container

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Overview

Multiple containerized applications can be run on a host, and containerized applications run on the host. We need to know the operation of the container, including CPU utilization, memory usage, network status, disk space and so on. And this information changes over time, which we call time series data. This article will practice how to build a visual monitoring center to collect the timing information of these containers carrying specific applications and visually analyze and display them!

Do it, do it.

Prepare for Mirror

Adviser: responsible for collecting container data over time influxdb: responsible for storing time series data grafana: responsible for analyzing and displaying time series data

Deploy Influxdb services

It can be thought of as a database service that is indeed used to store data. The reason for choosing this database is, as stated on the official website:

Open Source Time Series DB Platform for Metrics & Events (Time Series Data)

Let's deploy the service.

Docker run-d-p 8086 name influxdb tutum/influxdb 8086\-v ~ / influxdb:/var/lib/influxdb\-

Go inside the influxdb container and execute the influx command:

Docker exec-it influxdb influx

Create database test and root users for this test

CREATE DATABASE "test" CREATE USER "root" WITH PASSWORD 'root' WITH ALL PRIVILEGES

Deploy cAdvisor services

Google's cadvisor can be used to collect timing information about Docker containers, including resource usage and performance data while the container is running.

Run the cadvisor service

Docker run-d\-v /: / rootfs-v / var/run:/var/run-v / sys:/sys\-v / var/lib/docker:/var/lib/docker\-- link=influxdb:influxdb-- name cadvisor google/cadvisor:v0.27.3\-- storage_driver=influxdb\-- storage_driver_host=influxdb:8086\-storage_driver_db=test\-- storage_driver_user=root\-- storage_driver_password=root

Special attention items:

When running the above docker, there may be two other configuration items that need to be added (CentOS, required by RHEL):

-- privileged=true

When it is set to true, the root in the container has the real root permission, you can see the devices on the host, and you can execute mount;, otherwise the root in the container is just an external ordinary user right. Because cadvisor needs to access the docker daemon through socket, this option is required on CentOs and RHEL systems.

-- volume=/cgroup:/cgroup:ro

For some versions of CentOS and RHEL systems (such as CentOS6), the cgroup hierarchy is hung in the / cgroup directory, so you need to add an additional-volume=/cgroup:/cgroup:ro option when running cadvisor.

Deploy Grafana services

Grafana is an open source tool for analyzing time series data, and the interface is professional and easy to use. When you deploy it, you will feel it:

Docker run-d-p 5000 name grafana grafana/grafana 3000\-v ~ / grafana:/var/lib/grafana\-- link=influxdb:influxdb\-- name grafana grafana/grafana

So far, all three containers have been activated:

Let's start the concrete experiment.

Actual combat

Access the grafana service

Open localhost:5000 to access grafana's web service, which prompts you to log in. Note that the user name and password are admin.

After logging in, you can see the main page of grafana:

It is obvious that there are several steps to be done on Grafana. Now that Install Grafana is done, we need to:

Add data sourceCreate dashboard... ...

Add Data Source

Click Add data source to enter

Then there are mainly Setting tab settings

We need to fill in all the contents according to the actual situation:

Data source will be prompted if it is added successfully.

After the data source is added, we need to add the dashboard (Dashboard)

Add Dashboard

Click Add dashboard to enter

There are many types of dashboards to choose from. Let's just choose the most commonly used Graph.

After entering, click the Panel Title drop-down list, and then select Edit to edit.

The main thing in Edit is that you need to add query conditions. Continue to see below.

Add Query Editor

In the query conditions, we can select the metrics to be monitored:

Choose a memory usage here, and then choose grafana itself for the container you want to monitor.

Of course, you can monitor not only one indicator, but also more than one container. For more combinations, we just need to add query entries one by one below!

Finally, I added three monitoring conditions, which are used to monitor the memory usage metrics of grafana, influxdb and cadvisor containers, and display them in the diagram at the same time.

There are many other settings that can be explored here, such as some coordinate customization, display policy customization, and even we can customize the alarm policy and so on.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report