问题描述
我正试图将Flink的内置指标公开给Prometheus,但是Prometheus某种程度上无法识别目标-JMX和PrometheusReporter。
在prometheus.yml
中定义的抓取如下所示:
scrape_configs:
- job_name: node
static_configs:
- targets: ['localhost:9100']
- job_name: 'kafka-server'
static_configs:
- targets: ['localhost:7071']
- job_name: 'flink-jmx'
static_configs:
- targets: ['localhost:8789']
- job_name: 'flink-prom'
static_configs:
- targets: ['localhost:9249']
我的flink-conf.yml
有以下几行:
#metrics.reporters: jmx,prom
metrics.reporters: jmx,prometheus
#metrics.reporter.jmx.factory.class: org.apache.flink.metrics.jmx.JMXReporterFactory
metrics.reporter.jmx.class: org.apache.flink.metrics.jmx.JMXReporter
metrics.reporter.jmx.port: 8789
metrics.reporter.prom.class: org.apache.flink.metrics.prometheus.PrometheusReporter
metrics.reporter.prom.port: 9249
- 在IntelliJ中
- 如罐子:
java -jar target/flink-word-count.jar --input src/main/resources/loremipsum.txt
- 作为Flink作业:
flink run target/flink-word-count.jar --input src/main/resources/loremipsum.txt
根据Flink文档,我不需要JMX的任何其他依赖关系,也不需要flink-metrics-prometheus-1.10.0.jar
中为Prometheus记者提供的flink/lib/
的副本。
我在做什么错?缺少什么?
解决方法
我相信,这项工作很快就会完成。完成设置后,可能没有有趣的指标,因为该工作的运行时间不足以显示任何内容。
当您使用小型集群(如java -jar ...
运行时,flink-conf.yaml
文件不会被加载(除非您在工作中做了一些非常特殊的事情来加载它)。另请注意,该文件通常具有.yaml
扩展名;我不确定是否使用.yml
代替它。
您可以查看慢进管理器和任务管理器日志,以确保已加载报告程序。
FWIW,上一次我使用此设置是为了从多个过程中进行抓取:
# flink-conf.yaml
metrics.reporters: prom
metrics.reporter.prom.class: org.apache.flink.metrics.prometheus.PrometheusReporter
metrics.reporter.prom.port: 9250-9260
# prometheus.yml
scrape_configs:
- job_name: 'flink'
static_configs:
- targets: ['localhost:9250','localhost:9251']