Prometheus是一套开源的系统监控报警框架。Prometheus作为新一代的云原生监控系统,相比传统监控监控系统(Nagios或者Zabbix)拥有众多有点。
Download and install start exporte
[root@localhost ~]# wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
[root@localhost ~]# tar zxf node_exporter-0.18.1.linux-amd64.tar.gz
[root@localhost ~]# mv node_exporter-0.18.1.linux-amd64 /usr/local/node_exporte
[root@localhost ~]# /usr/local/node_exporte/node_exporter &
Download and install Prometheus
[root@localhost ~]# wget https://github.com/prometheus/prometheus/releases/download/v2.10.0/prometheus-2.10.0.linux-amd64.tar.gz
[root@localhost ~]# tar -zxf prometheus-2.10.0.linux-amd64.tar.gz
[root@localhost ~]# mv prometheus-2.10.0.linux-amd64 /usr/local/prometheus
Configure Prometheus
[root@localhost ~]# vim /usr/local/prometheus/prometheus.yml
# 修改如下
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
Start Prometheus
[root@localhost ~]# /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml &
Grafana
[root@localhost ~]# wget https://dl.grafana.com/oss/release/grafana-5.4.2-1.x86_64.rpm
[root@localhost ~]# yum -y install initscripts urw-fonts
[root@localhost ~]# rpm -Uvh grafana-5.4.2-1.x86_64.rpm
Start Grafana
[root@localhost ~]# systemctl start grafana-server
Grafana page configuration
visit http://192.168.1.10:3000
The default user password is admin to
create the display interface to monitor the data source.
Select
the service port of the host where Prometheus Prometheus is located.
Add a dashboard
. The blank space in the above figure needs to add a json file, which needs to be downloaded from the official website of grafana . Here you can choose the Docker instrument There are many types of disks, mainly for official use. Click here to use the ones to be used next. dashboard
After entering the page, as shown in the figure, you can download according to the red line in the figure
and then import the file into the Grafana page, select The data source is Prometheus
If you let Prometheus monitor multiple
nodes, download, install and start on the node nodeexporte
[root@localhost ~]# wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
[root@localhost ~]# tar zxf node_exporter-0.18.1.linux-amd64.tar.gz
[root@localhost ~]# mv node_exporter-0.18.1.linux-amd64 /usr/local/node_exporte
[root@localhost ~]# /usr/local/node_exporte/node_exporter &
Then go to the Prometheus node to modify the configuration file
[root@localhost ~]# vim /usr/local/prometheus/prometheus.yml
# 添加如下
- job_name: 'node'
static_configs:
- targets: ['localhost:9100','nodeIP:9100'] #node节点依次向后添加
Then re-run Prometheus
[root@localhost ~]# lsof -i:9100
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node_expo 9891 root 3u IPv6 47017 0t0 TCP *:jetdirect (LISTEN)
node_expo 9891 root 5u IPv6 54418 0t0 TCP localhost.localdomain:jetdirect->localhost.localdomain:50898 (ESTABLISHED)
prometheu 10322 root 8u IPv4 54416 0t0 TCP localhost.localdomain:51060->192.168.1.20:jetdirect (ESTABLISHED)
prometheu 10322 root 10u IPv4 54417 0t0 TCP localhost.localdomain:50898->localhost.localdomain:jetdirect (ESTABLISHED)
#先干掉之前的进程
kill -9 PID
#启动
/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml &
Restart Grafana and refresh the page to view
systemctl restart grafana-server