Prometheus是一套开源的系统监控报警框架。Prometheus作为新一代的云原生监控系统,相比传统监控监控系统(Nagios或者Zabbix)拥有众多有点。
下载安装启动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 &
下载安装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
配置Prometheus
[root@localhost ~]# vim /usr/local/prometheus/prometheus.yml
# 修改如下
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
启动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
启动Grafana
[root@localhost ~]# systemctl start grafana-server
Grafana页面配置
访问http://192.168.1.10:3000
默认用户密码都是admin
创建展示界面监控数据源
选择Prometheus
Prometheus所在主机的服务端口
添加仪表盘
上图中的空白处需要添加一个json文件,需要从grafana的官网进行下载,这里可以选择关于Docker的仪表盘,很多种类,这里以官方使用的为主,点击这里使用接下里要用的dashboard
,进入页面后,如图所示,根据图中红线处即可下载
然后将文件导入Grafana页面即可,选择数据源为Prometheus
如果让普罗米修斯监控多个节点
在node节点下载安装启动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 &
然后到普罗米修斯节点修改配置文件
[root@localhost ~]# vim /usr/local/prometheus/prometheus.yml
# 添加如下
- job_name: 'node'
static_configs:
- targets: ['localhost:9100','nodeIP:9100'] #node节点依次向后添加
然后重新运行普罗米修斯
[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 &
重启Grafana刷新页面查看
systemctl restart grafana-server
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/101831.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...