flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jiewen Shao <jiewens...@gmail.com>
Subject Re: need instruction on how the Flink metric works
Date Mon, 18 Sep 2017 04:22:00 GMT
Thanks, When I started jconsole, it listed
com.apache.flink.runtime.jobmanager..:[port]
as one of the Local Process, i was able to connect to it with insecure
connection, but i was not able to locate the Counter metrics, I only saw
some system metrics.

On Sun, Sep 17, 2017 at 7:39 PM, Michael Fong <mcfong.open@gmail.com> wrote:

> 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 <jiewenshao@gmail.com>
> wrote:
>
>> I'm new to flink and I have read https://ci.apache.org/pro
>> jects/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.get
>> ExecutionEnvironment();
>>
>>         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.
>>
>
>

Mime
View raw message