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

How to quickly deploy Prometheus Monitoring system

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

Share

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

How to quickly deploy the Prometheus monitoring system, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Here is a demonstration of how to quickly build a Prometheus monitoring system.

Environment description

We will monitor two Docker Host:192.168.56.102 and 192.168.56.103 through Prometheus, monitoring data at both host and container levels.

According to the architecture diagram, we need to run the following components:

Prometheus Server

Prometheus Server itself will also run as a container on host 192.168.56.103.

Exporter

Prometheus has many ready-made Exporter. For a complete list, please refer to https://prometheus.io/docs/instrumenting/exporters/.

We will use:

Node Exporter, responsible for collecting host hardware and operating system data. It will run as a container on all host.

CAdvisor, responsible for collecting container data. It will run as a container on all host.

Grafana

Display the multidimensional data, and Grafana itself will run as a container on host 192.168.56.103.

Run Node Exporter

Execute the following command on both host:

Docker run-d-p 9100lu 9100\

-v "/ proc:/host/proc"\

-v "/ sys:/host/sys"\

-v "/: / rootfs"\

-- net=host\

Prom/node-exporter\

-- path.procfs / host/proc\

-- path.sysfs / host/sys\

-- collector.filesystem.ignored-mount-points "^ / (sys | proc | dev | host | etc) ($| /)"

Notice that we use-- net=host here so that Prometheus Server can communicate directly with Node Exporter.

After Node Exporter starts, the monitoring data of host will be provided through 9100. Test it through http://192.168.56.102:9100/metrics in the browser.

Run cAdvisor

Execute the following command on both host:

Docker run\

-- volume=/:/rootfs:ro\

-- volume=/var/run:/var/run:rw\

-- volume=/sys:/sys:ro\

-- volume=/var/lib/docker/:/var/lib/docker:ro\

-- publish=8080:8080\

-- detach=true\

-- name=cadvisor\

-- net=host\

Google/cadvisor:latest

Notice that we use-- net=host here so that Prometheus Server can communicate directly with cAdvisor.

After cAdvisor starts, the monitoring data of host will be provided through 8080. Test it through http://192.168.56.102:8080/metrics in the browser.

The most important configurations are:

Static_configs:

-targets: ['localhost:9090','localhost:8080','localhost:9100','192.168.56.102:8080','192.168.56.102:9100']

Specify which exporter to grab data from. Node Exporter and cAdvisor on two host are specified here.

In addition, localhost:9090 is Prometheus Server itself, so it can be seen that Prometheus itself collects its own monitoring data. Similarly, we can also pass the http://192.168.56.103:9090/metrics test.

As shown in the following figure:

After logging in, Grafana will guide us to configure Data Source.

Url enter the address of Prometheus Server http://192.168.56.103:9090

To keep the default values for others, click Add.

If all goes well, Grafana should already be able to access the monitoring data stored in Prometheus, so how do you show it?

Grafana displays data through Dashboard, which needs to be defined in Dashboard:

What kind of multidimensional data is displayed in Prometheus? Specific query language expressions need to be given.

In what form, such as two-dimensional linear diagram, instrument chart, the meaning of various coordinates, etc.

It can be seen that it is not easy to make a Dashboard. Fortunately, we can use off-the-shelf Dashboard directly with the power of the open source community.

Visit https://grafana.com/dashboards?dataSource=prometheus&search=docker and you will see a lot of Dashboard used to monitor Docker.

We can download these off-the-shelf Dashboard, and then import into our Grafana can be used directly.

For example, download Docker and system monitoring, get a json file, and then click the menu in the upper left corner of Grafana, Dashboards-> Import.

Import the json file we downloaded.

Dashboard will show a beautiful chart right away.

In this Dashboard, the upper part is the data of host, and we can switch different host through Node.

The bottom half of the Dashboard shows all the container monitoring data. Grafana Dashboard is interactive, we can only show the specified container on the chart, select the specified time interval, reorganize and arrange the chart, adjust the refresh frequency, the function is very powerful.

This is the answer to the question on how to quickly deploy the Prometheus monitoring system. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

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