文档:
https://prometheus.fuckcloudnative.io/di-yi-zhang-jie-shao/overview
下载镜像包
sudo docker pull prom/node-exporter
sudo docker pull prom/prometheus
sudo docker pull grafana/grafana
启动node-exporter
sudo docker run -d -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" prom/node-exporter
访问url:
启动prometheus
新建目录 prometheus,编辑配置文件prometheus.yml
sudo mkdir /opt/prometheus
cd /opt/prometheus/
sudo 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: ['127.0.0.1:9100']
labels:
instance: localhost
启动prometheus
sudo docker run -d \
-p 9090:9090 \
-v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
如果grafana启动遇到问题: grafana报错Panel plugin not found grafana-piechart-panel
可以参考: https://blog.csdn.net/qq_41980563/article/details/121231939
访问url
127.0.0.1:9090/graph
启动grafana
新建空文件夹grafana-storage,用来存储数据
mkdir /opt/grafana-storage
设置权限
chmod 777 -R /opt/grafana-storage
启动grafana(如果和已有的端口冲突改一下端口)
sudo docker run -d \
-p 3000:3000 \
--name=grafana \
-v /opt/grafana-storage:/var/lib/grafana \
grafana/grafana
访问
127.0.0.1:3000