源码编译
- 下载Prometheus Server
#这里我们直接采用的是2.0的新版本
# wget https://github.com/prometheus/prometheus/releases/download/v2.0.0/prometheus-2.0.0.linux-amd64.tar.gz
# tar xf prometheus-2.0.0.linux-amd64.tar.gz -C /usr/local/
# mv /usr/local/prometheus-2.0.0.linux-amd64/ /usr/local/prometheus
- 提供配置文件
# mkdir /etc/prometheus
# cp /usr/local/prometheus/prometheus.yml /etc/prometheus/
- 提供数据存储路径
# mkdir /data/prometheus
- 启动服务
# /usr/local/prometheus/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus
- 查看服务监听端口
# ss -tlnp | grep 9090
LISTEN 0 128 :::9090 :::* users:(("prometheus",pid=2528,fd=3))
- 通过web访问
配置Prometheus服务,监听样本机实例
- 启动样本机
# wget https://github.com/prometheus/node_exporter/releases/download/v0.15.2/node_exporter-0.15.2.linux-amd64.tar.gz
# tar xf node_exporter-0.15.2.linux-amd64.tar.gz -C /usr/local/
# mv /usr/local/node_exporter-0.15.2.linux-amd64/ /usr/local/node_exporter
# /usr/local/node_exporter/node_exporter &
- 查看样本机数据
#node_exporter监听在9100端口
http://192.168.137.129:9090/metrics
- 将刚刚启动的node_exporter任务加到监控中
#在scrape_configs区域中加入如下配置,重启服务
- job_name: 'task'
static_configs:
- targets: ['192.168.137.129:9100']
labels:
group: 'production'
- 使用表达式,简单绘制图表 具体的数据指标可以从metrics返回的值中选取,假设,当前,我们需要了解机器可用的空闲内存,在Prometheus Server的web页面中"Graph",填入需要获取的值对应的key,点击"Execute"
到此,简单的安装就完成了