知乎专栏 |
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
firewall-cmd --zone=public --add-port=9090/tcp --permanent firewall-cmd --zone=public --add-port=3000/tcp --permanent firewall-cmd --zone=public --add-port=9191/tcp --permanent firewall-cmd --zone=public --add-port=9093/tcp --permanent firewall-cmd --zone=public --add-port=9323/tcp --permanent firewall-cmd --reload
查看端口策略是否已经生效
firewall-cmd --permanent --zone=public --list-ports