Function that aggregates by service and metric