Event logs are often stored as JSON Lines (one JSON object per line). Implement aggregate(lines, group_by, metric) returning a dict mapping each group value to {"count": n, "sum": s, "avg": a} over the numeric metric field.
Skip blank lines; lines that aren't valid JSON or lack either field are counted in a separate "_errors" key (an int) instead of crashing. Sort the result's keys (the error key last, and only present if there were errors).