You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Rinat <r....@cleverdata.ru> on 2019/03/07 16:52:47 UTC

expose number of entries in map state as a metric

Hi mates, I would like to expose the number of keys in MapState as a job metric

At first, I decided the Gauge metric is suitable for this purpose but then I think a little and decided that if I will iterate over the whole state on each request to Gauge, it will be too heavy.
So, I decided to create a counter, that will be incremented each time, when the item is added into state, and decrement it, when item is removed by key.

After this, I've added timers into my job and registering a timer on each key. However, I couldn’t pass any context into timer call, to remove only specified key, when timer is triggered and I’m skanning all
the state and removing all entries, whose expirationDate is less or equal to triggered time.

In the same method I’m decrementing the my counter.

I’ve found, when multiple timers are fired very often, my counter becomes less than 0. It means that I’m removing the same keys multiple times and decremting counter for a key more than once.

So I got the following questions:
what is the best approach to expose the number of the keys in map state as a metric
can I pass some context via timers to remove only specific keys after the specified amount of time

Thx a lot

Sincerely yours,
Rinat Sharipov
Software Engineer at 1DMP CORE Team

email: r.sharipov@cleverdata.ru <ma...@cleverdata.ru>
mobile: +7 (925) 416-37-26

CleverDATA
make your data clever