前言
本文以mac爲例,linux和windows類似。
一. 安裝軟件
1.首先安裝GO環境(使用brew):
brew install go
go version
go version go1.13 darwin/amd64
2.安裝Prometheus(https://prometheus.io/download/)
tar -zxvf prometheus-2.12.0.darwin-amd64.tar.gz -C /usr/local
ln -sv /usr/local/prometheus-2.12.0.darwin/ /usr/local/prometheus
配置prometheus.yml文件
啓動Prometheus
#直接啓動
prometheus --config.file=prometheus.yml
#可以根據指令關閉:curl -X POST http://localhost:9090/-/quit
prometheus --config.file=prometheus.yml --web.enable-lifecycle
#以守護進程啓動,關閉方式:pgrep-f prometheus查進程 kill -2 [pid]關閉
nohup prometheus --config.file=prometheus.yml --web.enable-lifecycle &
3.安裝Grafana
brew install grafana
看到下面的的信息,表示安裝成功
To have launchd start grafana now and restart at login:
brew services start grafana
Or, if you don't want/need a background service you can just run:
grafana-server --config=/usr/local/etc/grafana/grafana.ini --homepath /usr/local/share/grafana
cfg:default.paths.logs=/usr/local/var/log/grafana cfg:default.paths.data=/usr/local/var/lib/grafana
cfg:default.paths.plugins=/usr/local/var/lib/grafana/plugins
啓動關閉
#啓動
brew services start grafana
#關閉
brew services stop grafana
啓動驗證:grafana默認端口是3000,可以在瀏覽器中打開:http://127.0.0.1:3000
會進入登錄頁面:輸入用戶名:admin 密碼:admin即可進入,第一次登錄會提示修改密碼,可以跳過。