prometheus实战(二) 安装部署

源码编译

  • 下载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访问
    webmetrics

配置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"
    可用内存

到此,简单的安装就完成了

转载于:https://my.oschina.net/u/1987102/blog/1602471

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值