docker安装prometheus

2022-10-27 13:38:55 浏览数 (3)

# 1.拉取镜像

代码语言:javascript复制
[root@summer consoles]# docker pull prom/prometheus
[root@summer consoles]# docker pull grafana/grafana
[root@summer consoles]# docker pull prom/node-exporter
[root@summer consoles]# docker pull oliver006/redis_exporter

# 2.启动node-exporter

代码语言:javascript复制
[root@summer consoles]# docker run -d -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" prom/node-exporter
1c5f7096284d85ffbe38c16ba1f9a885b30a1bd5f6488d960b3a889ab7c8f384
  • 此时可访问IP:9100/metrics验证信息
  • 查看版本:
代码语言:javascript复制
/bin $ ./node_exporter --version
node_exporter, version 1.0.1 (branch: HEAD, revision: 3715be6ae899f2a9b9dbfd9c39f3e09a7bd4559f)
  build user:       root@1f76dbbcfa55
  build date:       20200616-12:44:12
  go version:       go1.14.4

# 3.启动prometheus

代码语言:javascript复制
[root@summer consoles]# mkdir /data/prometheus
mkdir: cannot create directory ‘/data/prometheus’: No such file or directory
[root@summer consoles]# mkdir -p /data/prometheus
[root@summer consoles]# cd /d
data/ dev/  
[root@summer consoles]# cd /data/prometheus/
[root@summer prometheus]# cat prometheus.yml 
global:
  scrape_interval:     60s
  evaluation_interval: 60s
 
scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus
  - job_name: summer
    static_configs:
      - targets: ['192.168.0.67:9100']
        labels:
          instance: summer

[root@summer prometheus]# docker run  -d -p 9090:9090 -v /data/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
1c6015a148f1572422b88e58bbe7e5f0a3474711c7bda8be08857f2a75484595
  • 此时可访问IP:9090验证信息
  • 查看版本:
代码语言:javascript复制
/bin $ ./prometheus --version
prometheus, version 2.23.0 (branch: HEAD, revision: 26d89b4b0776fe4cd5a3656dfa520f119a375273)
  build user:       root@37609b3a0a21
  build date:       20201126-10:56:17
  go version:       go1.15.5
  platform:         linux/amd64

# 4.启动grafana

代码语言:javascript复制
[root@summer prometheus]# mkdir -p /data/grafana/storage
[root@summer prometheus]# chmod 777 /data/grafana/storage
[root@summer prometheus]# docker run -d -p 3000:3000 --name=grafana -v /data/grafana/storage:/var/lib/grafana grafana/grafana
a85bbd3f9b16deac21d515f2b193f8d19224f3a74e50198b19e4d055dc1857b5
[root@summer prometheus]# 

0 人点赞