关于docker:基于docker-搭建PrometheusGrafana

42次阅读

共计 1100 个字符,预计需要花费 3 分钟才能阅读完成。

1. 下载镜像包

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

2. 启动 node-exporter

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

拜访 url:http://192.168.91.132:9100/me…

这些都是收集到数据,有了它就能够做数据展现了.

3. 启动 prometheus
新建目录 prometheus,编辑配置文件 prometheus.yml

mkdir /opt/prometheus
cd /opt/prometheus/
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

留神:批改 IP 地址,这里的 192.168.91.132 就是本机地址

启动 prometheus

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

拜访 url:
http://192.168.91.132:9090/graph

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

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

启动 grafana

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

拜访 url:
http://192.168.91.132:3000/

默认会先跳转到登录页面,默认的用户名和明码都是 admin

参考:https://www.cnblogs.com/xiao9…

正文完
 0