码迷,mamicode.com
首页 > 其他好文 > 详细

node-exporter+prometheus+grafana

时间:2019-07-09 15:28:49      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:mod   exp   --   plugins   net   issue   mct   tor   glob   

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

node-exporter+prometheus+grafana

标签:mod   exp   --   plugins   net   issue   mct   tor   glob   

原文地址:https://www.cnblogs.com/yintian908/p/11157447.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!