简体   繁体   English

使用 PrometheusPushGateway 报告 flink 指标时从 prometheus 获取代码 '200'

[英]Get code '200' from prometheus when using PrometheusPushGateway to report flink metrics

when i use flink-metrics-prometheus_2.11-1.10.0.jar to report metrics to prometheus, i got following errors, i want to know the reason for this problem and how can i solve it:当我使用 flink-metrics-prometheus_2.11-1.10.0.jar 向 prometheus 报告指标时,出现以下错误,我想知道这个问题的原因以及我该如何解决:

    2020-04-20 15:32:17.940 [Flink-MetricRegistry-thread-1] WARN  org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter  - Failed to push metrics to PushGateway with jobName oceanus, groupingKey {}.
java.io.IOException: Response code from http://9.91.161.72:80/metrics/job/oceanus was 200
        at org.apache.flink.shaded.io.prometheus.client.exporter.PushGateway.doRequest(PushGateway.java:297)
        at org.apache.flink.shaded.io.prometheus.client.exporter.PushGateway.push(PushGateway.java:127)
        at org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter.report(PrometheusPushGatewayReporter.java:109)
        at org.apache.flink.runtime.metrics.MetricRegistryImpl$ReporterTask.run(MetricRegistryImpl.java:441)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Seems like there was a recent change on how responses are handled .似乎最近处理响应的方式发生了变化。

I suspect you need to match the prometheus jar to the server version or vice versa.我怀疑您需要将普罗米修斯 jar 与服务器版本相匹配,反之亦然。

It seems flink-metrics-prometheus-1.10.0.jar contains a really old prometheus client java version ( https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-prometheus/pom.xml#L79 ,https://github.com/apache/flink/blob/release-1.9.1/pom.xml#L125 - 0.3.0 version). It seems flink-metrics-prometheus-1.10.0.jar contains a really old prometheus client java version ( https://github.com/apache/flink/blob/master/flink-metrics/flink-metrics-prometheus/pom. xml#L79https://github.com/apache/flink/blob/release-1.9.1/pom.xml#L125 - 0.3.0 版本)。

The annoying WARN on "200 OK" response code is fixed on 0.8.0 ( https://github.com/prometheus/client_java/blob/parent-0.8.0/simpleclient_pushgateway/src/main/java/io/prometheus/client/exporter/PushGateway.java#L316 ). “200 OK”响应代码上恼人的 WARN 已修复为 0.8.0( https://github.com/prometheus/client_java/blob/parent-0.8.0/simpleclient_pushgateway/src/main/java/io/prometheus/client /exporter/PushGateway.java#L316 )。 And that version is included since Flink 1.11.0 ( https://github.com/apache/flink/blob/release-1.11.0/pom.xml#L127 ).该版本自 Flink 1.11.0 ( https://github.com/apache/flink/blob/release-1.11.0/pom.xml#L127 ) 起包含在内。

So the solution is to include flink-metrics-prometheus-1.11.0.jar as part of your classpath.所以解决方案是将 flink-metrics-prometheus-1.11.0.jar 作为类路径的一部分。

Do not worry about Flink version incompatibility there because I'm using Flink 1.9.1 with flink-metrics-prometheus-1.11.0.jar and everything is working fine.不要担心那里的 Flink 版本不兼容,因为我正在使用 Flink 1.9.1 和 flink-metrics-prometheus-1.11.0.jar 并且一切正常。 I guess there was no so many changes on that part between Flink versions我想 Flink 版本之间的那部分没有太多变化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM