node-exporter+prometheus+grafana

1 系统安装docker


yum install -y docker
systemctl enable docker
systemctl start docker

2 下载镜像包:


docker pull prom/prometheus
docker pull prom/node-exporter
docker pull grafana/grafana

 

3启动node-exporter


3.1 启动镜像


docker run -d -p 9100:9100 -v /proc:/host/proc:ro -v /sys:/host/sys:ro -v /:/rootfs:ro --net=host prom/node-exporter

注:

  1. 试过以其他端口启动,不成功。
  2. 由于node-exporter是需要采集服务器的信息,所以,docker的net模式为 --net=host,意思是 docker使用的网络实际上和宿主机一样。


3.2 登陆

 

 

http://ipserver:9100/metrics

4 启动prometheus


4.1 新建目录prometheus,编辑配置文件prometheus.yml,内容如下


global:
scrape_interval: 60s
evaluation_interval: 60s

scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
labels:
instance: prometheus

- job_name: linux
static_configs:
- targets: ['ipserver:9100'] --这个是需要监控的linux服务器的地址
labels:
instance: localhost


4.2 启动prometheus


docker run -d -p 19090:9090 -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

 

4.3 登陆url

 

 

http://ipserver:19090/graph http://ipserver:19090/status


5 安装grafana


5.1 新建空文件夹/opt/grafana-storage


      mkdir /opt/grafana-storage
      chmod 777 -R /opt/grafana-storage

5.2 启动grafana


docker run -d -p 13000:3000 --name=grafana -v /opt/grafana-storage:/var/lib/grafana grafana/grafana


5.3 登陆url
    http://ipserver:13000/login

   ######错误######
  启动grafana容器出错的话,
  GF_PATHS_DATA='/var/lib/grafana' is not writable.
  You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later
  mkdir: cannot create directory '/var/lib/grafana/plugins': Permission denied

  ---------解决办法:chmod 777 -R /opt/grafana-storage

转载于:https://www.cnblogs.com/yintian908/p/11157447.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值