grafana我們這里采用docker方式部署
1、下載鏡像
鏡像官網地址:https://hub.docker.com/r/grafana/grafana/tags
[root@prometheus-server ~]# docker pull grafana/grafana:latest
2、啟動
[root@prometheus-server ~]# docker run \ -d \ -p 3000:3000 \ --name=grafana \ -v /etc/localtime:/etc/localtime:ro \ grafana/grafana
3、訪問
瀏覽器打開http://10.10.0.13:3000,用戶名密碼:admin
4、為Grafana添加Prometheus數據源
Name:定義數據源的名字;
URL:Prometheus 服務的IP地址和端口;
其他保持默認,然后點擊測試並保存。
5、創建Dashboard
5.1 New Dashboard
5.2 選擇模型
5.3 添加CPU使用率圖形
5.4 更改標題
其他默認保存,其它監控項添加類似,下面為一個完整Dashboard。
注意:
對於Grafana創建Dashboard界面,如果對Grafana不熟悉,我們可以從Grafana官網下載對應模板,然后導入再進行簡單修改,以符合自己的監控Dashboard面板。
模板地址:https://grafana.com/dashboards
特別注意因為node_exporter是比較老的組件,有一些dashboard模板都是基於老版本node_exporter開發,所以一些指標名稱有些不一樣
例如:
* node_cpu -> node_cpu_seconds_total * node_memory_MemTotal -> node_memory_MemTotal_bytes * node_memory_MemFree -> node_memory_MemFree_bytes * node_filesystem_avail -> node_filesystem_avail_bytes * node_filesystem_size -> node_filesystem_size_bytes * node_disk_io_time_ms -> node_disk_io_time_seconds_total * node_disk_reads_completed -> node_disk_reads_completed_total * node_disk_sectors_written -> node_disk_written_bytes_total * node_time -> node_time_seconds * node_boot_time -> node_boot_time_seconds * node_intr -> node_intr_total
導入模板步驟:
1、查找模板
這里我選用這個node_exporter模板:https://grafana.com/dashboards/8919
然后下載json文件
2、導入模板
3、導入完成后,可以看到以下Dashboard界面
以上就是現有模板導入的操作,有時候我們使用別人的模板有些圖不一定會出圖形,這時候我們需要看下圖形公式是否正確,相應調整即可,更多模板請參考:https://grafana.com/dashboards