[英]Prometheus not showing flink metrics
我的 flink 工作中有以下代碼;
@Override
public void open(Configuration config) {
this.counter = getRuntimeContext()
.getMetricGroup()
.counter("myCounter");
}
@Override
public Tuple2<String, String> map(String s) throws Exception {
this.counter.inc();
Thread.sleep(5000);
return new Tuple2<String, String>(s, s.toUpperCase());
}
在 prometheus 發行版中的 prometheus.yml 中,我有以下內容:
- job_name: 'flink-prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9999']
metrics_path: /
而在 flink-conf.yaml 里面的 flink 分布:
metrics.reporters: prom
metrics.reporter.prom.class: org.apache.flink.metrics.prometheus.PrometheusReporter
metrics.reporter.prom.host: 127.0.0.1
metrics.reporter.prom.port: 9999
在 prometheus 板上,我可以看到 localhost:9999 作為目標,以及各種指標日志。 但是我在代碼中添加的計數器沒有日志。 我搜索了字符串“myCounter”以及“flink-prometheus”,但結果為零。
我還需要做什么才能顯示我的指標?
我在https://github.com/mbode/flink-prometheus-example中的示例和您自己的配置之間看到的主要區別是該示例正在抓取作業管理器以及任務管理器:
scrape_configs:
- job_name: 'flink'
static_configs:
- targets: ['job-cluster:9249', 'taskmanager1:9249', 'taskmanager2:9249']
在我自己的示例中——參見Flink Timing Explorer——我發現也有必要這樣做。 這對我有用:
flink-conf.yaml
metrics.reporters: prom
metrics.reporter.prom.class: org.apache.flink.metrics.prometheus.PrometheusReporter
metrics.reporter.prom.port: 9250-9260
普羅米修斯.yaml
global:
scrape_interval: 5s
evaluation_interval: 5s
scrape_configs:
- job_name: 'flink'
static_configs:
- targets: ['host.docker.internal:9250', 'host.docker.internal:9251']
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.