1. 程式人生 > 其它 >通過Docker安裝 Prometheus 和node-exporter 檢視版本

通過Docker安裝 Prometheus 和node-exporter 檢視版本

[root@node ~]# mkdir /opt/prometheus
[root@node ~]# cd /opt/prometheus/
[root@node ~]# vim 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.91.132:9100'] labels: instance: localhost #啟動容器 [root@node ~]# docker run -d -p 9090:9090 -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus #檢視容器 [root@node ~]# docker container ls #獲取版本號 [root@node
~]# docker exec -it 75d4e24396ae /bin/prometheus --version prometheus, version 2.34.0 (branch: HEAD, revision: 881111fec4332c33094a6fb2680c71fffc427275) build user: root@121ad7ea5487 build date: 20220315-15:18:00 go version: go1.17.8 platform: linux/amd64

檢視node-exporter版本

[root@node ~]# docker pull prom/node-exporter
[root@node ~]# docker images | grep node-exporter
prom/node-exporter   latest   1dbe0e931976  4 months ago    20.9MB
#啟動容器
[root@node ~]# docker run -d -p 9100:9100 \
-v "/proc:/host/proc:ro" \
  -v "/sys:/host/sys:ro" \
  -v "/:/rootfs:ro" \
  --net="host" \
  prom/node-exporter
#啟動容器
[root@node ~]# docker run -d -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" --net="host" prom/node-exporter
#檢視容器
[root@node ~]# docker container ls
#獲取版本號
[root@node ~]# docker exec -it 7c6d4d897c82 /bin/node-exporter --version
node_exporter, version 1.3.1 (branch: HEAD, revision: a2321e7b940ddcff26873612bccdf7cd4c42b6b6)
  build user:       root@243aafa5525c
  build date:       20211205-11:09:49
  go version:       go1.17.3
  platform:         linux/amd64