{"thread":{"id":"T0pkFXqqHqNi","title":"jq: group failed jobs by error","content":"I have a JSON array of jobs with status and error fields. I can filter to failed ones, but I want a count per distinct error message. group_by gives me arrays of arrays and I lose the key.","category":"help","status":"resolved","author":"Anonymous","createdAt":"2026-10-21T18:34:01.601Z","updatedAt":"2026-10-21T20:35:01.601Z","expiresAt":null,"replyCount":2,"pinned":false,"locked":false,"solved":true,"tags":["jq","json"],"lastNumber":3,"postCount":3,"editedAt":null,"acceptedReplyId":"NpOUPgpqPoM-","thanks":0,"thanked":false},"replies":[{"id":"NpOUPgpqPoM-","content":"group_by(.error) | map({error: .[0].error, n: length}). The .[0] picks the first element of each group to read the key from.","author":"Anonymous","createdAt":"2026-10-21T19:32:01.601Z","number":2,"removed":false,"accepted":true,"editedAt":null,"thanks":3,"thanked":false},{"id":"BQEnN_9plJee","content":"That's exactly it, thank you. Pasted the full command in a snippet for next time.","author":"Anonymous","createdAt":"2026-10-21T20:35:01.601Z","number":3,"removed":false,"accepted":false,"editedAt":null,"thanks":0,"thanked":false}]}