Prometheus 監(jiān)控flink

提要

本文主要介紹將flink任務(wù)運(yùn)行的metric發(fā)送到Prometheus

監(jiān)控的意義

flink流式任務(wù)在實(shí)時(shí)性穩(wěn)定性方面都有一定的要求,通過(guò)Prometheus 采集flink集群的metric,指定一些指標(biāo)就可以對(duì)其進(jìn)行監(jiān)控告警。從而能夠讓開(kāi)發(fā)人員快速反應(yīng),及時(shí)處理線上問(wèn)題。

1.Prometheus 簡(jiǎn)介

Prometheus是一個(gè)開(kāi)源的監(jiān)控和報(bào)警系統(tǒng)。https://prometheus.io/docs/introduction/overview/

2.1特性

  • 多維度的數(shù)據(jù)模型(通過(guò)指標(biāo)名稱(chēng)和標(biāo)簽鍵值對(duì)標(biāo)識(shí))
  • 靈活的查詢(xún)語(yǔ)言
  • 單機(jī)工作模式,不依賴(lài)于分布式存儲(chǔ)
  • 通過(guò)pull模式(HTTP)收集監(jiān)控?cái)?shù)據(jù)
  • 通過(guò)使用中間件可以支持push監(jiān)控?cái)?shù)據(jù)到prometheus
  • 通過(guò)服務(wù)發(fā)現(xiàn)或者靜態(tài)配置發(fā)現(xiàn)目標(biāo)(監(jiān)控?cái)?shù)據(jù)源)
  • 支持多模式的畫(huà)圖和儀表盤(pán)

2.2組件

Prometheus生態(tài)系統(tǒng)包含很多組件(大多是都是可選擇的)

  • Prometheus server(抓取、存儲(chǔ)時(shí)間序列數(shù)據(jù))
  • client libraries(幫助應(yīng)用支持prometheus數(shù)據(jù)采集)
  • a push gateway(支持短生命周期的jobs,接收push的監(jiān)控?cái)?shù)據(jù))(prometheus原生支持pull工作模式,為了兼容push工作模式)
  • exporters(用于支持開(kāi)源服務(wù)的監(jiān)控?cái)?shù)據(jù)采集,比如:HAProxy、StatsD、Graphite等)(也就是agent)
  • alertmanager(處理警報(bào))

2.3架構(gòu)

下面這張圖展示了prometheus的建構(gòu)和prometheus系統(tǒng)可能需要到的組件:


image.png

3 flink集成prometheus

3.1 flink配置

詳細(xì)配置參考
https://ci.apache.org/projects/flink/flink-docs-stable/monitoring/metrics.html#cpu
進(jìn)入flink目錄

image.png

拷貝 opt目錄下的flink-metrics-prometheus-1.7.2.jar 到lib目錄。

編輯conf/flink-conf.yml

metrics.reporter.promgateway.class: org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter
metrics.reporter.promgateway.host: test01.cdh6.local
metrics.reporter.promgateway.port: 9091
metrics.reporter.promgateway.jobName: myJob
metrics.reporter.promgateway.randomJobNameSuffix: true
metrics.reporter.promgateway.deleteOnShutdown: false

3.2 pushgateway安裝

參考 https://github.com/prometheus/pushgateway
訪問(wèn) http://test01.cdh6.local:9091/#

image.png

3.3 prometheus安裝

參考 http://www.itdecent.cn/p/3a9ede07d963
本例prometheus和pushgateway安裝到同一機(jī)器上
編寫(xiě) prometheus.yml

scrape_configs:
  - job_name: 'pushgateway'
    static_configs:
      - targets: ['localhost:9091']
        labels:
          instance: 'pushgateway'

啟動(dòng)
./prometheus --config.file=prometheus.ym l
這個(gè)9091端口就是flink-conf.yml 對(duì)應(yīng)的metrics.reporter.promgateway.port: 9091
flink會(huì)把一些metric push到9091端口上,然后prometheus采集。

4效果

啟動(dòng)flink集群 .bin/start-cluster.sh
訪問(wèn) http://test01.cdh6.local:9090

image.png

總結(jié)

flink metric數(shù)據(jù)流轉(zhuǎn)的流程是 flink metric -> pushgateway -> prometheus

todo 配置告警策略

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Prometheus對(duì)比Zabbix 和Zabbix類(lèi)似,Prometheus也是一個(gè)近年比較火的開(kāi)源監(jiān)控框架,和...
    Cloudox_閱讀 44,382評(píng)論 0 49
  • 文章目的: 1、向沒(méi)聽(tīng)過(guò)或者剛聽(tīng)過(guò)但是還對(duì)這個(gè)監(jiān)控系統(tǒng)沒(méi)有任何概念的開(kāi)發(fā)者介紹Prometheus的應(yīng)用場(chǎng)景。2、...
    whaike閱讀 39,979評(píng)論 15 59
  • Prometheus TSDB是什么? (Time Series Database) 簡(jiǎn)單的理解為.一個(gè)優(yōu)化后用來(lái)...
    ilkkzm閱讀 19,377評(píng)論 0 4
  • 主機(jī)數(shù)據(jù)收集 主機(jī)數(shù)據(jù)的采集是集群監(jiān)控的基礎(chǔ);外部模塊收集各個(gè)主機(jī)采集到的數(shù)據(jù)分析就能對(duì)整個(gè)集群完成監(jiān)控和告警等功...
    梅_梅閱讀 6,783評(píng)論 0 7
  • 憶昔年仲夏,立于那廣袤無(wú)垠之地,仰望白云朵朵,聆聽(tīng)蟲(chóng)鳴嗡嗡。似這般心曠神怡,實(shí)為難得。有殷殷切切之心,有鶴立雞群之...
    云清月行閱讀 421評(píng)論 1 4

友情鏈接更多精彩內(nèi)容