Group metrics by prefix