1. Node_exporter profile

Node-exporter collects server running indicators, including loadavg, Filesystem, and meminfo

2. Grafana profile

Grafana is an open source data visualization and analysis tool that allows you to visualize metrics regardless of where they are stored. At the same time, it also has an alarm function, when the indicator exceeds the specified range will alert you.

3. Introduction of Prometheus

Prometheus is a timing database that can be understood simply as a MySQL database with time. Since Grafana only converts data into visual diagrams and has no storage capability, we needed to use it in conjunction with a sequential database like Prometheus.

4. Install

  • downloadnode_explorerInstallation package, download address:Prometheus. IO/download / # n…

  • This time, let’s go straight tonode_explorerInstall the installation package on a Linux server (if a Docker container is used to install the installation package, the indicators of the Docker container will be monitored), decompress the downloaded installation package to a specified directory, and change the folder name
CD /mydata tar -zxvf node_exporters 1.1.2.linux-amd64.tar.gz MV node_exporters 1.1.2.linux-amd64 node_exportersCopy the code
  • Go to the decompressed directory and run the following commandnode_explorer, the service will run on9100On port
cd node_exporter
nohup ./node_exporter >log.file 2>&1 &
Copy the code
  • usecurlCommand to access the interface for obtaining indicator information. If the indicator information is obtained, the operation is successful
curl http://localhost:9100/metrics
Copy the code

  • Automatically install Docker using the official installation script
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
Copy the code
  • Download the Docker image of Grafana
docker pull grafana/grafana
Copy the code
  • Run Grafana
docker run -p 3000:3000 --name grafana -d grafana/grafana
Copy the code
  • Download the Docker image for Prometheus
docker pull prom/prometheus
Copy the code
  • Create a configuration file for Prometheusprometheus.yml(Create folders by yourself)
vi /mydata/prometheus/prometheus.yml
Copy the code
global:
  scrape_interval: 30s
  scrape_timeout: 30s
scrape_configs:
  - job_name: node
    static_configs:
    - targets: ['127.0.0.1:9100']
Copy the code
  • Run Prometheus to install the configuration file in the hostprometheus.ymlMount it into a container
docker run -p 9090:9090 --name prometheus -v /mydata/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -d prom/prometheus
Copy the code

5. Graphical display

Grafana access address:http://192.168.120.51:3000The user nameadminpasswordadmin(You can change the password after login)

Configure the data source (just enter the Intranet IP address)

Importing a template (enter 1860 for the TEMPLATE ID)

More templates can be viewed hereGrafana.com/grafana/das… Select the data source you just configured

See the effect

6. Reference materials

  • Grafana Official documentation: grafana.com/docs/grafan…
  • The use of the node – exporter: Prometheus. IO/docs/guides…
  • Prometheus – Configuration file related soulchild.cn/1965.html

Reference 7.

  • Zhihu article: zhuanlan.zhihu.com/p/389489129