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
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。