Andreas Kunze
03/09/2023, 5:45 PMclass MyCustomMetric extends RichMapFunction[String, String] {
@transient private var valueToExpose = 0
override def open(parameters: Configuration): Unit = {
getRuntimeContext()
.getMetricGroup()
.addGroup("MyMetricKey", "MyMetricValue")
.gauge[Int, ScalaGauge[Int]]("MyGauge", ScalaGauge[Int]( () => valueToExpose ) )
}
override def map(value: String): String = {
valueToExpose += 1
return value
}
}
First of all, from my understanding, the addGroup(key, value) will define a User-Variable and this will be exported to Prometheus as a label, is that correct?
I configured the necessary settings for exporting metrics to Prometheus and it's working for the default Flink system metrics.
However, I have some problems with my custom metric:
1. When using the code above as it is, the metric is not accessible at all, neither from the Flink Web UI nor from Prometheus
2. Without using the addGroup(key, value) part the metric is accessible from the Flink Web UI and Prometheus but, of course, with any additional custom label
Can anyone help me understand what I'm doing wrong or what's missing here?Andreas Kunze
03/10/2023, 1:02 PM