知乎專欄 | 多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者” |
目錄
docker run -d -p 9090:9090 -v ~/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus -config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000
docker run -d -p 9100:9100 --user 995:995 \ -v "/:/hostfs" \ --net="host" \ prom/node-exporter \ --path.rootfs=/hostfs
檢查 node-exporter 是否正常工作
$ curl http://localhost:9100/metrics
安裝 grafana
$ docker run -d --name grafana -p 3000:3000 --net=host -e "GF_SECURITY_ADMIN_PASSWORD=passw0rd" grafana/grafana
-e "GF_SERVER_ROOT_URL=http://grafana.server.name"
docker exec -it grafana cat /etc/grafana/grafana.ini > grafana.ini
環境變數配置的預設路徑
環境變數 預設值 GF_PATHS_CONFIG /etc/grafana/grafana.ini GF_PATHS_DATA /var/lib/grafana GF_PATHS_HOME /usr/share/grafana GF_PATHS_LOGS /var/log/grafana GF_PATHS_PLUGINS /var/lib/grafana/plugins GF_PATHS_PROVISIONING /etc/grafana/provisioning
$ docker service create --replicas 1 --name prometheus \ --mount type=bind,source=`pwd`/prometheus.yml,destination=/etc/prometheus/prometheus.yml \ --publish published=9090,target=9090,protocol=tcp \ prom/prometheus