当前位置:   article > 正文

Docker 安装Node-Exporter+ Prometheus Server +Grafana_192.168.2.192:9090

192.168.2.192:9090

下载镜像

docker pull prom/node-exporter
docker pull prom/prometheus
docker pull grafana/grafana
  • 1
  • 2
  • 3

安装node-export

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
  • 3
  • 4
  • 5
  • 6

查看端口:

[root@dev-002 ~]# netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1080/sshd           
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      1880/docker-proxy   
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1240/master         
tcp        0     52 192.168.0.152:22        192.168.2.192:59308     ESTABLISHED 1811/sshd: root@pts 
tcp6       0      0 :::9100                 :::*                    LISTEN      2180/node_exporter  
tcp6       0      0 :::22                   :::*                    LISTEN      1080/sshd           
tcp6       0      0 :::3000                 :::*                    LISTEN      1886/docker-proxy   
tcp6       0      0 ::1:25                  :::*                    LISTEN      1240/master         
tcp6       0      0 192.168.0.152:9100      172.17.0.3:54128        ESTABLISHED 2180/node_exporter 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

访问url

http://192.168.0.152:9100/metrics
  • 1

新建Prometheus文件夹:

mkdir /opt/prometheus
cd /opt/prometheus/
vim prometheus.yml
  • 1
  • 2
  • 3

编辑配置文件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: ['192.168.0.152:9100']
        labels:
          instance: localhost
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

启动prometheus

docker run  -d \
  -p 9090:9090 \
  -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  \
  prom/prometheus
  • 1
  • 2
  • 3
  • 4
[root@dev-002 ~]# netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:9090            0.0.0.0:*               LISTEN      2013/docker-proxy   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1080/sshd           
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      1880/docker-proxy   
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1240/master         
tcp        0     52 192.168.0.152:22        192.168.2.192:59308     ESTABLISHED 1811/sshd: root@pts 
tcp6       0      0 :::9090                 :::*                    LISTEN      2020/docker-proxy   
tcp6       0      0 :::9100                 :::*                    LISTEN      2180/node_exporter  
tcp6       0      0 :::22                   :::*                    LISTEN      1080/sshd           
tcp6       0      0 :::3000                 :::*                    LISTEN      1886/docker-proxy   
tcp6       0      0 ::1:25                  :::*                    LISTEN      1240/master         
tcp6       0      0 192.168.0.152:9100      172.17.0.3:54128        ESTABLISHED 2180/node_exporter 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

访问url

http://192.168.0.152:9090/graph
  • 1

启动grafana

新建空文件夹grafana-storage,用来存储数据

mkdir /opt/grafana-storage
  • 1

设置权限

chmod 777 -R /opt/grafana-storage
  • 1

因为grafana用户会在这个目录写入文件,直接设置777

启动grafana

docker run -d \
  -p 3000:3000 \
  --name=grafana \
  -v /opt/grafana-storage:/var/lib/grafana \
  grafana/grafana
  • 1
  • 2
  • 3
  • 4
  • 5

查看端口状态

[root@dev-002 ~]# netstat -anpt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:9090            0.0.0.0:*               LISTEN      2013/docker-proxy   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1080/sshd           
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      1880/docker-proxy   
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1240/master         
tcp        0     52 192.168.0.152:22        192.168.2.192:59308     ESTABLISHED 1811/sshd: root@pts 
tcp6       0      0 :::9090                 :::*                    LISTEN      2020/docker-proxy   
tcp6       0      0 :::9100                 :::*                    LISTEN      2180/node_exporter  
tcp6       0      0 :::22                   :::*                    LISTEN      1080/sshd           
tcp6       0      0 :::3000                 :::*                    LISTEN      1886/docker-proxy   
tcp6       0      0 ::1:25                  :::*                    LISTEN      1240/master         
tcp6       0      0 192.168.0.152:9100      172.17.0.3:54128        ESTABLISHED 2180/node_exporter 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

访问url:

http://192.168.91.132:3000/
​
  • 1
  • 2

配置:Grafana
配置数据源
在这里插入图片描述
配置:dashboards

UID:11074
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/946089
推荐阅读
相关标签
  

闽ICP备14008679号