Apache flink 未能将普罗米修斯仪表注册到弗林克
我试图在Flink应用程序中暴露普罗米修斯仪表:Apache flink 未能将普罗米修斯仪表注册到弗林克,apache-flink,prometheus,Apache Flink,Prometheus,我试图在Flink应用程序中暴露普罗米修斯仪表: @transient def metricGroup: MetricGroup = getRuntimeContext.getMetricGroup .addGroup("site", site) .addGroup("sink", counterBaseName) @transient var failedCounter: Counter = _ def expose(metricName: String, gaugeVal
@transient def metricGroup: MetricGroup = getRuntimeContext.getMetricGroup
.addGroup("site", site)
.addGroup("sink", counterBaseName)
@transient var failedCounter: Counter = _
def expose(metricName: String, gaugeValue: Int, context: SinkFunction.Context[_]): Unit = {
try {
metricGroup.addGroup("hostname", metricName).gauge[Int, ScalaGauge[Int]]("test", ScalaGauge[Int](() => gaugeValue))
}
} catch {
case _: Throwable => failedCounter.inc()
}
}
该应用程序在本地运行良好,并且没有任何问题地公开指标
在尝试转入生产时,我在Flink task manager中遇到以下异常:
WARN org.apache.flink.runtime.metrics.MetricRegistryImpl-注册度量时出错。java.lang.NullPointerException
不确定,我在这里错过了什么
为什么本地应用程序在集群上无法注册度量时会公开度量
我使用Prometheus来公开Flink的其他度量,例如,代码中的failedCounter是一个计数器
这是我第一次在Flink中公开gauge,所以我敢打赌我的实现中的某些东西被破坏了
请提供帮助。首先通过配置文件/etc/prometheus/prometheus.yml确保普罗米修斯正在从flink收集数据 在flink-conf.yaml上配置普罗米修斯 确保所有任务管理器的lib目录中都有prometheus jar库,并且flink和scala的版本与您使用的相匹配:flink-metrics-prometheus_2.11-1.10.0.jar。 启动群集时,请确保已加载普罗米修斯:
./flink-flink-standalonesession-0-cow-11.log:51:2020-06-15 15:07:02,915 INFO org.apache.flink.metrics.prometheus.PrometheusReporter - Started PrometheusReporter HTTP server on port 9250.
./flink-flink-standalonesession-0-cow-11.log:52:2020-06-15 15:07:02,917 INFO org.apache.flink.runtime.metrics.MetricRegistryImpl - Reporting metrics for reporter prom of type org.apache.flink.metrics.prometheus.PrometheusReporter.
然后您可以从中的Hello world仪表示例开始。首先通过配置文件/etc/prometheus/prometheus.yml确保prometheus正在从flink收集数据 在flink-conf.yaml上配置普罗米修斯 确保所有任务管理器的lib目录中都有prometheus jar库,并且flink和scala的版本与您使用的相匹配:flink-metrics-prometheus_2.11-1.10.0.jar。 启动群集时,请确保已加载普罗米修斯:
./flink-flink-standalonesession-0-cow-11.log:51:2020-06-15 15:07:02,915 INFO org.apache.flink.metrics.prometheus.PrometheusReporter - Started PrometheusReporter HTTP server on port 9250.
./flink-flink-standalonesession-0-cow-11.log:52:2020-06-15 15:07:02,917 INFO org.apache.flink.runtime.metrics.MetricRegistryImpl - Reporting metrics for reporter prom of type org.apache.flink.metrics.prometheus.PrometheusReporter.
然后您可以从中的Hello world gauge示例开始。如果您可以粘贴整个堆栈跟踪,而不仅仅是异常,那么跟踪错误可能会更容易。好的,我想我找到了问题,但不确定如何解决它。名称冲突:组已包含名为“被\u服务器拒绝\u”的度量。将不报告度量。[10.199.193.172,taskmanager,0536B010099D06A2693D3DCAD8833AB060,rtbRejectedCounter,接收器:PrometheusSink,0,站点,null,接收器,PrometheusSink,主机名,was-prd-web60]如何运行get或create gauge和get或create Metric?有趣的是为什么本地人工作时没有错误;代码没有引用“被\u服务器拒绝的\u”。“gaugeValue”是否保证为非空?正确,我将仪表名称从被拒绝的\u服务器更改为test,不同的是代码是相同的。该值不能为空,但可以为0。我想我应该以某种方式与MetricRegistry合作,但到目前为止我还没有找到例子。你多久打一次电话给expose?每个子任务只能注册一次度量值。如果可以粘贴整个堆栈跟踪,而不仅仅是异常,那么跟踪错误可能会更容易。好的,我想我发现了问题,但不确定如何解决它。名称冲突:组已包含名为“被\u服务器拒绝\u”的度量。将不报告度量。[10.199.193.172,taskmanager,0536B010099D06A2693D3DCAD8833AB060,rtbRejectedCounter,接收器:PrometheusSink,0,站点,null,接收器,PrometheusSink,主机名,was-prd-web60]如何运行get或create gauge和get或create Metric?有趣的是为什么本地人工作时没有错误;代码没有引用“被\u服务器拒绝的\u”。“gaugeValue”是否保证为非空?正确,我将仪表名称从被拒绝的\u服务器更改为test,不同的是代码是相同的。该值不能为空,但可以为0。我想我应该以某种方式与MetricRegistry合作,但到目前为止我还没有找到例子。你多久打一次电话给expose?每个子任务只能注册一次度量。我已经在Flink中使用了普罗米修斯。这不是配置问题。既然你说在集群上它无法注册仪表?我试图帮助在集群中配置普罗米修斯。我看不出有理由否决我的答案。至少这有助于验证你的配置。不是我:我已经在弗林克使用普罗米修斯了。这不是配置问题。既然你说在集群上它无法注册仪表?我试图帮助在集群中配置普罗米修斯。我看不出有理由否决我的答案。至少这有助于验证您的配置。不是我:
./flink-flink-standalonesession-0-cow-11.log:51:2020-06-15 15:07:02,915 INFO org.apache.flink.metrics.prometheus.PrometheusReporter - Started PrometheusReporter HTTP server on port 9250.
./flink-flink-standalonesession-0-cow-11.log:52:2020-06-15 15:07:02,917 INFO org.apache.flink.runtime.metrics.MetricRegistryImpl - Reporting metrics for reporter prom of type org.apache.flink.metrics.prometheus.PrometheusReporter.