標籤(空格分隔): flink系列 node
一:flink監控簡介linux
二:Flink的Metric架構git
- 三: prometheus + grafana 的 對 flink 的監控部署構建
Flink提供的Metrics能夠在Flink內部收集一些指標,經過這些指標讓開發人員更好地理解做業或集羣的狀態。因爲集羣運行後很難發現內部的實際情況,跑得慢或快,是否異常等,開發人員沒法實時查看全部的Task日誌,好比做業很大或者有不少做業的狀況下,該如何處理?此時Metrics能夠很好的幫助開發人員瞭解做業當前情況。對於不少大中型企業來說,咱們對進羣的做業進行管理時,更多的是關心做業精細化實時運行狀態。例如,實時吞吐量的同比環比、整個集羣的任務運行概覽、集羣水位,或者監控利用 Flink 實現的 ETL 框架的運行狀況等,這時候就須要設計專門的監控系統來監控集羣的任務做業狀況。
Flink Metrics是Flink實現的一套運行信息收集庫,咱們不但能夠收集Flink自己提供的系統指標,好比CPU、內存、線程使用狀況、JVM垃圾收集狀況、網絡和IO等,還能夠經過繼承和實現指定的類或者接口打點收集用戶自定義的指標。 經過使用Flink Metrics咱們能夠輕鬆地作到: • 實時採集Flink中的Metrics信息或者自定義用戶須要的指標信息並進行展現; • 經過Flink提供的Rest API收集這些信息,而且接入第三方系統進行展現。
從Flink Metrics架構來看,指標獲取方式有兩種。一是REST-ful API,Flink Web UI中展現的指標就是這種形式實現的。二是reporter,經過reporter能夠將metrics發送給外部系統。Flink內置支持JMX、Graphite、Prometheus等系統的reporter,同時也支持自定義reporter。 因爲Flink Web UI所提供的metrics數量較少,也沒有時序展現,沒法知足實際生產中的監控需求。Prometheus+Grafana是業界十分普及的開源免費監控體系,上手簡單,功能也十分完善。
Prometheus自己也是一個導出器(exporter),提供了關於內存使用、垃圾收集以及自身性能 與健康狀態等各類主機級指標。 prometheus官網下載址: https://prometheus.io/download/ wget https://github.com/prometheus/prometheus/releases/download/v2.21.0/prometheus-2.21.0.linux-amd64.tar.gz # tar zxvf prometheus-2.21.0.linux-amd64.tar.gz # mv prometheus-2.21.0.linux-amd64 /usr/local/prometheus # chmod +x /usr/local/prometheus/prom* # cp -rp /usr/local/prometheus/promtool /usr/bin/
最後 加上pushgateway 收集: 此處將pushgateway 與 prometheus 安裝在一臺機器上面 - job_name: 'linux' static_configs: - targets: ['192.168.100.15:9100'] labels: app: node05 nodename: node05.vpc.flyfish.cn role: node - job_name: 'pushgateway' static_configs: - targets: ['192.168.100.15:9091'] labels: instance: 'pushgateway'
prometheus 的開機啓動: cat > /usr/lib/systemd/system/prometheus.service <<EOF [Unit] Description=Prometheus [Service] ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml -- storage.tsdb.path=/usr/local/prometheus/data --web.enable-lifecycle --storage.tsdb.retention.time=180d Restart=on-failure [Install] WantedBy=multi-user.target EOF --- #service prometheus start #chkconfig prometheus on
node_exporter : #tar -zxvf node_exporter-1.0.1.linux-amd64.tar.gz #mv node_exporter-1.0.1.linux-amd64 /usr/local/node_exporter #/usr/local/node_exporter/node_exporter &
pushgateway: #tar -zxvf pushgateway-1.2.0.linux-amd64.tar.gz #mv pushgateway-1.2.0.linux-amd64 /usr/local/pushgateway/ # /usr/local/pushgateway/pushgateway &
###3.4 flink metric 的配置github
flink-conf.yaml 到最後加上 ---- metrics.reporter.promgateway.class: org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter metrics.reporter.promgateway.host: 192.168.100.15 metrics.reporter.promgateway.port: 9091 metrics.reporter.promgateway.jobName: pushgateway metrics.reporter.promgateway.randomJobNameSuffix: true metrics.reporter.promgateway.deleteOnShutdown: true ---- 而後同步全部flink的 works 節點
重啓flink 的集羣 ./stop-cluster.sh ./start-cluster.sh