I want new counter for every key of my windowed stream, And I want the same counter to get increment when the same key comes multiple times in incoming event.
So, I will write below code for every incoming event. getRuntimeContext().getMetricGroup().counter(myKey).inc(); But above code fails when same value of myKey comes. As this is limitation of flink metrics. It throws exception, "Name collision: Adding a metric with the same name as a metric subgroup: " Note: myKey is of String type and can have different value for every incoming event. In my case I expect 100 thousands different values of myKey. Now, To solve the issue, I have to keep the reference of 100 thousands values of myKey in some data structure e.g. Map<String, Counter> myMetricMap; and for every myKey I have to do below. Counter counter = myMetricMap.get(myKey); if (null == windowMetricGauge) { Counter counter = new counter(); counter.inc(); myMetricMap.put(myKey, counter); getRuntimeContext().getMetricGroup().counter(myKey,counter); } else { counter.inc(); } Above code suffice my purpose. But I do not want to maintain map of 100 thousands keys values of myKey. Is there any alternate solution? I am looking for a solution where I achieve above functionality to maintain approx. 100 thousands counter metrics without keeping their reference in map (or any other data structure). Thanks & Regards Gaurav Luthra Mob:- +91-9901945206