node_expoter 用于采集服务器数据
promethous 用于采集数据的存储、计算和提供server服务
grafana 用于数据的渲染
最终效果如下:
node_expoter
命令行安装或官方下载
wget -c https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
解压
tar zxvf prometheus-2.15.1.linux-amd64.tar.gz
启动
./node_exporter &
启动成功后访问 http://{ip}:9100,可以看到如下页面,表示启动成功
访问 http://{ip}:9100/metrics,可以看到所采集的信息
promethous
下载解压
- linux
wget -c https://github.com/prometheus/prometheus/releases/download/v2.15.1/prometheus-2.15.1.linux-amd64.tar.gz
tar zxvf prometheus-2.15.1.linux-amd64.tar.gz
- mac
brew install prometheus
编写配置文件,在prometheus.yml中加入如下配置(mac为/usr/local/etc/prometheus.yml):
- job_name: 'tencent'
static_configs:
- targets: ['{ip}:9100'] # node_expoter所安装的服务器
启动
- linux
直接在安装目录下 ./prometheus - mac
prometheus --config.file=/usr/local/etc/prometheus.yml &
启动成功后访问 http://{ip}:9090/targets,能看到如下页面,表示启动成功
grafana
官网下载地址:Grafana
根据自己的系统版本和配置,下载对应的包,官方提供了如下说明,可直接按照说明进行下载:
启动
# linux
# service grafana-server start
# mac
# brew services start grafana
浏览器访问http://{ip}:3000就可以看到Grafana页面,默认账号密码都是admin
选择数据源
选择prometheus
定义监控名、url
导入dashboards,这里推荐两个默认模板 11074/8919
点击manage
点击import
输入id(11074/8919 两个模板内容一样,前者为英文,后者为中文),点击load
返回首页,可以看到刚配置的模板
点击进去,就可以看到服务器的监控情况了。
到这里, node_expoter + promethous + grafana的安装与启动就结束了!