部署 Linux 操作系统监控组件
1. 下载监控 Linux 的 exporter
https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_expor
ter-0.18.1.linux-amd64.tar.gz
2. 将 node_exporter 包上传到需要被监控的 Linux 服务器上任意目录下,执行解压命
令
tar xvf node_exporter-0.18.1.linux-amd64.tar.gz
3. 进入到解压后的文件夹中,执行启动脚本
nohup ./node_exporter &
查看 nohup 日志:tail -100 nohup.out,出现如下日志,代表启动成功

部署 prometheus
1、 下载包
https://github.com/prometheus/prometheus/releases/download/v2.15.2/promethe
us-2.15.2.linux-amd64.tar.gz
2、 将 prometheus 上传到一台单独的 Linux 机器上,执行解压操作
tar xvf prometheus-2.15.2.linux-amd64.tar.gz
3、 进入到解压后的文件夹中,修改配置文件,添加要监控的服务器信息 10.0.0.71
vi prometheus.yml
在 scrape_configs 配置项下添加 Linux 监控的 job,其中
IP 修改为上面部署 node_exporter 机器的 ip,端口号为 9100,注意缩进
- job_name: 'node'
static_configs:
- targets: ['10.0.0.71:9100']

# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
- job_name: "node"
static_configs:
- targets: ["192.168.88.151:9100"]
4、 保存配置文件,启动 prometheus
nohup ./prometheus &
检查 nohup.out 日志,如果有以下信息,启动成功

在浏览器中访问部署的 prometheus:http://ip:9090
点击菜单栏“Status-Targets”,看到页面中有如下 node 节点,代表 prometheus 和
node_exporter 链接成功

注意
- 因其他业务已占用9100端口,需修改为其他端口
# 启动时指定端口
$ nohup ./node_exporter --web.listen-address=:7100 &
Grafana导入监控模板
添加promethus数据源
输入URL点击保存
导入监控模板
打开 grafana 官网,查找官网提供的 prometheus 监控模板
https://grafana.com/grafana/dashboards
点击 Linux 服务器监控的模板,记录该模板的 id:11074

在 grafana 系统页面中,通过 id 导入该模板,即可在 grafana 中看到 机器
的性能监控数据
选择刚刚添加的promethus数据源