Hi,

You may enable metrics reporter to see the output of your metrics; counter
in your example.

There is a brief documentation regarding to metrics and reporter setup at
link
<https://ci.apache.org/projects/flink/flink-docs-release-1.4/monitoring/metrics.html>.
The easiest approach, in my opinion, is to set up a JMX reporter so that
you may see your metrics via JConsole.

Hope this helps.

Regrads,


On Mon, Sep 18, 2017 at 10:27 AM, Jiewen Shao <jiewens...@gmail.com> wrote:

> I'm new to flink and I have read https://ci.apache.org/
> projects/flink/flink-docs-release-1.3/monitoring/metrics.html, I am still
> unclear where do I read the metrics I added.
>
> for example,
>
> public static void main(String[] args) throws Exception {
>
>
>         StreamExecutionEnvironment env = StreamExecutionEnvironment.
> getExecutionEnvironment();
>
>         env.setParallelism(2);
>
>
>
>         List<String> wordList = Arrays.asList("Hive", "Presto", "Impala",
> "Parquet","ORC","Hadoop", "Flink", "Spark", "Storm", "Tez", "Flink");
>
>
>         DataStreamSource<String> source = env.fromCollection(wordList);
>
>         DataStream<Tuple2<String, Integer>> dataStream = env
> .fromCollection(wordList).map(new WordLengthCounter());
>
>         dataStream.print();
>
>         env.execute();
>
>     }
>
>
> and
>
>
> public class WordLengthCounter extends RichMapFunction<String,
> Tuple2<String, Integer>> {
>
>
> private static final long serialVersionUID = 1L;
>
> private Counter counter;
>
>
> @Override
>
>   public void open(Configuration config) {
>
>     this.counter = getRuntimeContext()
>
>       .getMetricGroup()
>
>       .counter("myCounter");
>
>   }
>
>
> @Override
>
> public Tuple2<String, Integer> map(String value) throws Exception {
>
> this.counter.inc();
>
> return new Tuple2<String, Integer>(value, value.length());
>
> }
>
> }
>
>
> Now, where do I see the counter? Sorry for the naive question
>
> can anyone point me to any good end-to-end "hello world" example for flink
> metrics.
>

Reply via email to