1. Basic structure diagram

Architecture analysis:

The main modules of Prometheus include Server, Exporters, Pushgateway, PromQL, Alertmanager, WebUI, etc.

The general logic is as follows: 1.Prometheus Server periodically pulls data from targets that are statically configured or discovered by the Targets service. 2. Prometheus persists data to disk (if remote storage is used to persist data to the cloud) when the newly pulled data exceeds the configured memory cache. 3.Prometheus can configure rules, query data periodically, and push alerts to the configured Alertmanager when conditions are triggered. 4. When an Alertmanager receives a warning, it can aggregate, de-duplicate, de-noise, and send a warning based on the configuration. 5. Data can be queried and aggregated using the API, Prometheus Console, or Grafana.

Storage:

As shown in the architecture diagram of Prometheus, Prometheus provides local storage, the TSDB sequential database. The advantage of local storage is that it is easy to operate and maintain, but the disadvantage is that the massive metrics persistence is not available and the data may be lost. In actual use, wal files have been damaged for several times and cannot be written again.

Of course, after prometheus2.0, the ability to compress data has been greatly improved. To overcome the limitation of single-node storage, Prometheus did not implement its own cluster storage, but provided a remote read and write interface, allowing users to choose the appropriate timing database to achieve Prometheus scalability. Prometheus interconnects with other remote storage systems in either of the following ways: Prometheus writes metrics to a remote storage system in a standard format Prometheus reads metrics from a remote URL in a standard format

Second, the installation

Installation Procedure

Install the Prometheus server

CD /usr/local/kernel mkdir -p /usr/local/prometheus/ tar -zxvf Prometheus -2.12.0.linux-amd64.tar.gz -c /usr/local/ Prometheus/CD /usr/local/ Prometheus/mv Prometheus -2.12.0. Linux-amd64 / Prometheus -server Starts the Prometheus server Listen on port 9090 curl -x POST http://localhost:9090/-/reload resume service command vi/usr/local/Prometheus/Prometheus – server/Prometheus. Yml CD /usr/local/prometheus/prometheus-server nohup ./prometheus –web.enable-lifecycle &

Install pushgateway

Gz -c /usr/local/prometheus/ CD /usr/local/prometheus/ Mv pushgateway – 0.9.1. Linux – amd64 pushgateway

Enable pushGateway to listen on port 9091

cd /usr/local/prometheus/pushgateway nohup ./pushgateway &

Install base Node – Exporter

Gz -c /usr/local/prometheus/ CD /usr/local/kernel tar -zxvf node_exin-0.18.1.linux-amd64.tar. gz -c /usr/local/prometheus/ CD / usr/local/Prometheus/mv node_exporter – 0.18.1. Linux – amd64 / usr/local/Prometheus/node_exporter node_exporter start listening port 9100 cd /usr/local/prometheus/node_exporter nohup ./node_exporter &

Install grafana

RPM Listen on port 3000. The default user name and password are admin service grafana-server start CD /usr/local/kernel unzip Camptocamp – grafana – Prometheus – alertmanager – a datasource – 0.0.7-0 – gc4d8c51. Zip mv camptocamp-grafana-prometheus-alertmanager-datasource-c4d8c51 /var/lib/grafana/plugins/camptocamp-grafana-prometheus-alertmanager-datasource

Install alarm plug-in

CD /usr/local/kernel tar -zxvf alertManager-0.19.0.linux-amd64.tar. gz -c /usr/local/prometheus/ CD / usr/local/Prometheus/mv alertmanager – 0.19.0. Linux – amd64 / alertmanager

Start alertManager to listen to port 9093

cd /usr/local/prometheus/alertmanager nohup ./alertmanager

cd /usr/local/kernel

Tar -zxvf mysqLD_support-0.11.0.linux-amd64.tar. gz -c /usr/local/prometheus/ CD /usr/local/prometheus mv Mysqld_exporter – 0.11.0. Linux – amd64 mysqld_exporter

Listen for port 9104

cd /usr/local/prometheus/mysqld_exporter nohup ./mysqld_exporter –config.my-cnf=”my.cnf” &

Install the service grafana-server restart plug-in

CD /usr/local/kernel unzip percona-grafana-app-v1.0.0-0-g8264b8e.zip mv percona-grafana-app-8264b8e /var/lib/grafana/plugins/percona-grafana-app

Always start

cd /usr/local/prometheus/prometheus-server nohup ./prometheus –web.enable-lifecycle & nohup /usr/local/prometheus/pushgateway/pushgateway & service grafana-server start cd /usr/local/prometheus/alertmanager nohup ./alertmanager

Always close

ps ax|grep prometheus|grep -v grep|awk ‘{print 1}’|xargs kill -9 ps ax|grep alertmanager|grep -v grep|awk ‘{print 1}’|xargs kill -9 service grafana-server stop