"No metrics available" indicates that either
a) metrics have not been queried yet or
b) metrics can not be transferred from the TaskManagers to the JobManager.

Regarding the first option, how long have you waited for metrics to show up? It may take a bit for metrics to be available (around 10 seconds).

As for the second, you'll have to set the log level to DEBUG and search for metric related errors.

On 19/04/2019 08:23, sora wrote:
Hi all,
I am trying to monitor my flink application, so I add two metric in my application. But I can not see any information on the web. The metric tab says "No metrics available".
Do I miss any config?
My flink version: 1.7.2
My example code:
def main(args: Array[String]) {

   val env = StreamExecutionEnvironment.getExecutionEnvironment    
env.setStreamTimeCharacteristic(TimeCharacteristic.ProcessingTime)

val text = env.socketTextStream("HOST", 6666)
   val counts = text.flatMap(new RichFlatMapFunction[String, String] {
     private var counter: Counter = _
     private var meter: org.apache.flink.metrics.Meter = _

     override def open(parameters: Configuration):Unit = {
       super.open(parameters)
       counter = getRuntimeContext.getMetricGroup.counter("recordCounter")
       meter = getRuntimeContext.getMetricGroup.meter("recordMeter", new 
DropwizardMeterWrapper(new com.codahale.metrics.Meter()))
     }

     override def flatMap(value:String, out: Collector[String]):Unit = {
       val result = value.split("\\W+").filter(_.nonEmpty)
       result.foreach(out.collect)
       counter.inc(result.length)
       meter.markEvent(result.length)
     }
   })
     .map {
       (_, 1L)
     }
     .keyBy(_._1)
     .timeWindow(Time.seconds(5))
     .sum(1)
     .map {
       _.toString()
     }

   counts.addSink(new SocketClientSink[String]("HOST", 7777, new 
SimpleStringSchema))

   env.execute("Scala SocketTextStreamWordCount Example")
}


Reply via email to