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 build Grafana+Prometheus Monitoring system

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

Share

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

This article is about how to build a Grafana+Prometheus monitoring system. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1 installation and deployment

Grafana+Prometheus+Exporter is often used to monitor multiple servers. The architecture diagram of this monitoring framework is as follows:

Fig. 1 architecture diagram of monitoring system

Exporter collects the performance metrics of the local host on a regular basis.

Prometheus collects the index data of multiple Exporter and stores them in prometheus database.

Grafana is a visual panel, which can display the data of prometheus index database in a variety of display forms. at the same time, Grafana provides a large number of developed visual panels for use, most of which do not need to be developed.

Let's take the windows platform as an example to build a monitoring system.

1.1 Exporter installation

The name of Exporter varies from operating system to operating system. Under Linux, it is windows_exported under node-exported,Windows.

Download the installation package from https://github.com/prometheus-community/windows_exporter/releases and execute the command under windows:

Msiexec / I "windows_exporter-0.16.0-amd64.msi" ENABELD_COLLECTORS= "os,cpu,cs.logical_disk,net,system,process" LISTEN_PORT= "19182" EXTRA_FLAGS= "- collector.process.whitelist=abc | windows_exporter"

Where LISTEN_PORT= "19182" is the access port number for configuring Exporter, which can be modified.

When you visit http://localhost:19182/metrics after the installation is completed, you can see that Metrics is successful:

1.2 Prometheus installation

Prometheus stores time series data, that is, a collection of consecutive data stored in a time dimension in the same time sequence (same name and label).

Time series is defined by a name (Metric) and a set of key/value tags, with the same name and tags belonging to the same timing.

Installation steps under Linux:

Wget https://github.com/prometheus/prometheus/releases/download/v2.12.0/prometheus-2.12.0.linux-amd64.tar.gz

Tar-zxf prometheus-2.12.0.linux-amd64.tar.gz

Mv prometheus-2.12.0.linux-amd64 prometheus

Chown root.root prometheus-R

# start directly

Nohup. / prometheus-- config.file=prometheus.yml 2 > & 11 > prometheus.log &

# View Services

[root@VM_0_13_centos pushgateway] # netstat-lntup | grep prometheus

Tcp6 0 0: 9090: * LISTEN 16655/prometheus

Installation steps under windows:

Download the prometheus-2.26.0.windows-amd64.zip package directly, decompress it, configure prometheus.yml, and then start prometheus. The default port is 9090.

Prometheus configuration

The main thing to configure is that the collection object targets,targets supports multiple.

If there are multiple hosts in a job, you only need to configure multiple ip and ports in the targets, separated by commas

[root@bogon prometheus] # cat prometheus.yml | grep-v'#'| grep-v ^ $| tail-n 7

Scrape_configs:

-job_name: 'prometheus'

Static_configs:

-targets: ['localhost:9090','localhost:19182']

-job_name: 'node'

Static_configs:

-targets: ['192.168.68.17purl 9100']

After rebooting, you can see that Targets in prometheus looks like this:

State=UP said that prometheus has successfully collected data from Exporter.

1.3 Grafana installation configuration

Grafana is an open source data visualization tool developed in GE language, which can do data monitoring and statistics.

Download the latest version of the compressed package for the corresponding environment from the grafana official website. The default port is 3000.

Build dashboard, such as charts, status values, tables, and so on. There are many ready-made Dashboard on the official website that can be imported (https://grafana.com/grafana/dashboards) in two ways: one is to download the json file of the corresponding dashboard from the website; the other is to enter the ID of dashboard in the grafana console.

Install the monitoring panel

Click the "Import" button

The Import interface supports both ID and json import methods.

Enter 10467 in the add interface to add the prometheus monitoring panel for windows. (Linux monitoring panel: 8919re9276, etc.; Windows monitoring panel: 10467).

The schematic diagram of UI is as follows:

Note that for windows and linux platforms, the panels for monitoring Exporter data are incompatible with each other, so be sure to adapt to the type of operating system.

[note]

If you open the Import interface and display something like this:

Then you must click the Cancel button before you can enter the blank Import interface.

Thank you for reading! This is the end of this article on "how to build a Grafana+Prometheus monitoring system". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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