node_expoter 用於採集服務器數據
promethous 用於採集數據的存儲、計算和提供server服務
grafana 用於數據的渲染
最終效果如下:
node_expoter
命令行安裝或官方下載
wget -c https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
解壓
tar zxvf prometheus-2.15.1.linux-amd64.tar.gz
啓動
./node_exporter &
啓動成功後訪問 http://{ip}:9100,可以看到如下頁面,表示啓動成功
訪問 http://{ip}:9100/metrics,可以看到所採集的信息
promethous
下載解壓
- linux
wget -c https://github.com/prometheus/prometheus/releases/download/v2.15.1/prometheus-2.15.1.linux-amd64.tar.gz
tar zxvf prometheus-2.15.1.linux-amd64.tar.gz
- mac
brew install prometheus
編寫配置文件,在prometheus.yml中加入如下配置(mac爲/usr/local/etc/prometheus.yml):
- job_name: 'tencent'
static_configs:
- targets: ['{ip}:9100'] # node_expoter所安裝的服務器
啓動
- linux
直接在安裝目錄下 ./prometheus - mac
prometheus --config.file=/usr/local/etc/prometheus.yml &
啓動成功後訪問 http://{ip}:9090/targets,能看到如下頁面,表示啓動成功
grafana
官網下載地址:Grafana
根據自己的系統版本和配置,下載對應的包,官方提供瞭如下說明,可直接按照說明進行下載:
啓動
# linux
# service grafana-server start
# mac
# brew services start grafana
瀏覽器訪問http://{ip}:3000就可以看到Grafana頁面,默認賬號密碼都是admin
選擇數據源
選擇prometheus
定義監控名、url
導入dashboards,這裏推薦兩個默認模板 11074/8919
點擊manage
點擊import
輸入id(11074/8919 兩個模板內容一樣,前者爲英文,後者爲中文),點擊load
返回首頁,可以看到剛配置的模板
點擊進去,就可以看到服務器的監控情況了。
到這裏, node_expoter + promethous + grafana的安裝與啓動就結束了!