聲明:本系列部落格是根據sgg的視訊整理而成,非常适合大家入門學習。
《2021年最新版大資料面試題全面開啟更新》
在flink配置⽂件flink-conf.yaml中添加:
将flink包中opt檔案下的flink-metrics-prometheus-xxxxx.jar包複制到lib檔案夾中
2.1 下載下傳prometheus到window上
prometheus 的下載下傳連結為:
https://prometheus.io/download/
下載下傳 pushgateway-1.3.0.windows-amd64.tar.gz 後解壓
3.1 下載下傳prometheus到window上
下載下傳 prometheus-2.22.0.windows-amd64.tar.gz 後解壓
這裡所需prometheus的元件為:
prometheus
pushgateway(flink推送監控資料到此)
将這些元件分别解壓到任意目錄。
3.2 配置prometheus
修改prometheus根目錄<code>prometheus.yml</code>檔案的scrape_config,如下圖所示:
因為prometheus配置pushgateway 的時候,也會指定job和instance,但是它隻表示 pushgateway執行個體,不能真正表達收集資料的含義。是以配置pushgateway需要添加 honor_labels:true,避免收集資料本身的job和instance被覆寫。
4 grafana 配置
4.1 下載下傳并啟動grafana
下載下傳grafana解壓,添加prometheus資料源。
grafana的下載下傳位址為: https://grafana.com/grafana/download
5.1 先啟動 pushgateway
通過cmd啟動 pushgateway.exe
檢視metrics:
通路對應元件的url,例如<code>http://10.180.210.172:9091/metrics</code>(初次安裝這裡為空白)
5.2 再啟動 prometheus
通過cmd啟動prometheus.exe
檢視各個endpoint是否成功注冊在prometheus:
通路prometheus首頁(9090端口),打開status -> targets,觀察各個endpoint的status是否為up。
5.3 啟動flink
5.4 啟動grafana
通過cmd啟動grafana-server.exe
5.4.2 配置grafana
配置資料源
grafana預設運作在3000端口。使用預設使用者名密碼(admin/admin)登入grafana後,選擇左側菜單的configuration -> data sources。
接下來點選右側的<code>add data source</code>按鈕。在資料源類型選擇中界面選擇<code>prometheus</code>。
最後,将prometheus的位址端口号填寫入url這一欄,點選下方的<code>save & test</code>按鈕。如果配置無誤,會彈出資料源正常連接配接的提示資訊。
選擇左側菜單的create -> dashboard,然後選擇<code>add query</code>。
dashboard的add panel,add query。會進入到名額查詢配置頁面。
打開query右側的下拉清單,選擇使用的資料源。
接下來配置查詢語句。有以下兩種方式點選metrics按鈕,根據分類選擇監控名額。或者是在文本框中輸入名額的關鍵字。
查詢語句配置完畢後,頁面上方會顯示出監控資料,如圖所示。
傳回dashboard後可以看到配置的監控圖已經固定到了頁面當中,友善以後檢視。