MB-8282: Filter out buckets first

Otherwise we may access buckets whose data are not collected.

Change-Id: Id650087b47380f17e5d650c661fc28982a9964ad