Build a small RESTful API that ingests a provided dataset and returns aggregated metrics. Implement the core behavior as aggregate_metrics(records, group_by, metric_fields). Return one result per group, with count, sum, minimum, maximum, and average for every requested numeric field, ordered by group value.
Input records are dictionaries with a string grouping field and numeric metric fields. Return a list of dictionaries with keys group, count, and metrics; return [] for an empty dataset.
def aggregate_metrics(records, group_by, metric_fields):