# 如何將 Grafana 監控平台移植到新 Server 上 ### 一、轉移 Grafana 檔案 官方下載連結: https://grafana.com/grafana/download Edition: 選擇**OSS(Open Source Software)**\ 作業系統: 依照自身電腦選擇對應的即可 * Windows: 直接點擊 Download the installer 下載 * Linux: [Linux 作業系統下載 Grafana 步驟](https://hackmd.io/@KenLiang/grafana-linux)  --- #### Grafana 資料夾需要更改的地方 (or 將原電腦開發完的 Grafana 整包打包移植過去) ``` 1.更改登入 Title : grafana\public\build\5893.0cedc4c919aff84ce58c.js (1) 修改 LoginTitle (2) 修改 AppTitle 2.更改分頁 Title : grafana\public\build\DashboardPage.DashboardPage.0cedc4c919aff84ce58c.js 修改 {if (e.dashboard!==r&&(document.title=r.title+" - "+ "你想輸入的Title") 3.更改 Logo : grafana\public\img (1) grafana_icon.svg (左上角logo) (2) fav32.png (分頁圖示) 4.email alert功能(未完成): grafana\conf\sample.ini [smtp] 設定調整 ``` 詳細操作說明(附圖): 1.[Grafana 更改登入 Title 與分頁 Title](https://hackmd.io/@KenLiang/grafana-title) 2.[Grafana 更改 Logo](https://hackmd.io/@KenLiang/grafana-logo) Grafana 預設 port 為3000,網址: **http://localhost:3000** 預設登入帳號/密碼 : **admin / admin** --- ### 二、建立 Data Source 1.裝 XAMPP 並設定好 Apache 與 MySQL  2.打開 XAMPP MySQL 依以下名稱並按照格式建立資料庫與資料表(名稱可自訂,不過 API Server 與 Grafana 上的對應名稱也要跟著更改) ### 資料庫 * test_table ### 資料表 * device_info: modbus name 與客戶序號的 mapping table,並包含 AI 訓練狀況等資訊 * tb_status: 所有設備前/後端的最新狀態與異常特徵 * anomaly_log: 過去 model 偵測到異常(黃紅燈)狀態的所有紀錄 * tb_feature: 儲存各種 feature 的 data log * tb_fft: 儲存 x,y,z 三軸 fft 的 data log * tb_error_log: 過去 error 的所有紀錄 * error_code_list: error code 對應表(404:網路連線異常, 704:AI model 訓練異常) 3.打開 Grafana -> Configuration -> Add data source -> MySQL  4.填完紅框處資料庫的設定就可以點下方 Save & test 測試有沒有連接成功 Name: 之後在 panel 選取 data source 時顯示的名稱 Host: IP address : 資料庫的 port (例 localhost:3306) Database: 填入欲當資料來源的資料庫名稱 User/Password: 資料庫帳號/密碼  --- ### 三、匯入 Plugin Import dashboard 之前必須先匯入 plugin,不然會抓不到該 plugin 而顯示錯誤 #### 如何匯入 plugin Server Admin -> Plugins -> Search Grafana plugins  #### 需要下載的 plugins 有: * static * dynamic image panel * button panel * plotly panel ### 四、匯入 Dashboard (JSON檔) 1.Import -> Upload JSON file (設定好的 dashboard 的 JSON檔會放在 bitbucket 上)  2.填入 Name, Folder(決定 dashboard 所放的資料夾), UID,按下 Import  3.依序匯入首頁、Feature、FFT、Device state 四個 dashboard 即完成 4.打開 Browse 將首頁放在 General folder,另外再開一個 folder 放 Feature、FFT 與 Device state --- ### 匯入 dashboard 問題 #### 1. 遇到讀取 panel 出現 error edit panel -> 重新選擇一次 data source -> Apply #### 2. 設定首頁 將該首頁打星星(mark as favorite) -> Configuration -> Preferences -> Home dashboard 找到並選取首頁 -> Save #### 3. Dynamic image panel 跑不出圖 將 data source 設為 static (要先到 plugin 找到 static **Create a Static data source**) -> Fields (Name: img Type: String) -> Values (base64 的值) ###### tags: `Grafana` `tutorials`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up