grafana+prometheus+node_exporter監控環境搭建
一.grafana安裝:
grafana:專門用於資料展示的前端平臺,通過瀏覽器來訪問,沒有資料儲存
注:grafana最好網上下載最新版本,否則一定機率會出現模板報錯的問題,如下:
安裝grafana
` yum install grafana-7.4.3-1.x86_64.rpm -y`
具體需要看下載的grafana版本和格式而定
啟動:systemctl restart grafana-server
二:prometheus安裝:
開源,直接解壓就可以使用
tar.gz包,解壓,然後啟動 `./prometheus
預設埠: 9090 http://prometheus_ip:9090
三:安裝node_exporter
需要注意的是,node_exporter需要安裝到被測伺服器上,用於監控伺服器資料,而grafana則要安裝到壓測機器上面
解壓tar.gz包 然後啟動 `./node_exporter`
預設埠:9100 http://node_exporter_ip:9100
配置:
1)prometheus + node_exporter結合
修改prometheus配置檔案: prometheus.yml,並加入以下片段:
```
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: 'kyj_node_exporter'
static_configs:
- targets: ['192.168.3.41:9100','192.168.3.57:9100']
```
2)grafana 中配置展示Prometheus中的資料
登入
add data source 選擇 prometheus
URL填入prometheus的安裝電腦Ip:http://prometheus_ip:9090
import 模板
訪問grafana: http://grafana-server-ip:3000 預設使用者名稱和密碼為: admin admin
大概效果如下展示:
搜尋
複製