學習 Flink(十):監控
指標系統
TODO
Prometheus
配置 Flink
首先,執行cp opt/flink-metrics-prometheus-1.8.0.jar lib/
,將依賴的 JAR 檔案拷貝到/lib
目錄下。
然後,編輯conf/flink-conf.yaml 檔案,新增配置:
metrics.reporter.prom.class: org.apache.flink.metrics.prometheus.PrometheusReporter
可選配置metrics.reporter.prom.port
,Prometheus Exporter 監聽埠,預設為9249
。
可選配置metrics.reporter.prom.filterLabelValueCharacters
,指定是否過濾不匹配[a-zA-Z_][a-zA-Z0-9_]*
的 Label,預設為false
。
重新啟動 Flink 叢集,Flink Prometheus 指標地址在 JobManager 所在主機的 9249 埠。
配置 Prometheus
編輯prometheus.yml 配置檔案,新增 Flink 叢集指標配置:
scrape_configs: - job_name: 'flink' metrics_path: '/' static_configs: - targets: ['FLINK_MASTER:9249']
啟動 Prometheus:
prometheus --config.file=prometheus.yml
Grafana
Grafana 是開源的儀表盤應用,官方支援 Prometheus 作為資料來源。
新增 Prometheus 資料來源,匯入Flink Metrics 。