Counting passes or failures by label (multiple unwrap?)

I’m trying to get a list of taskIds (a generated label) with > n failures and 0 successes. I have the query below which generates a table like this. In this example, I’d like to put a table on a dashboard with just the task2 row as it has 0 successes and > n failures.

TaskId Result Count
1 Success 4
1 Failure 10
2 Success 0
2 Failure 20

Query:

sum by(result, taskID) (count_over_time(
    {my_label_filters} 
    |= `Logging end of task` 
    | regexp `.*Logging end of task (?P<taskName>.*) \(ID(?P<taskID>.*)\): (?P<result>.*)\r` 
    [$__auto]))

One idea was to generate labels with label_format but I can’t figure out how to count them. I think I need to unwrap all labels generated and from one other post from 2023 the only suggestion was to use multiple queries which I think would cause performance issues. Does anyone see how this could be modified to achieve my goal?

sum(taskID? Successes?  Failures?)  sum_over_time(
    {my_label_filters} 
    |= `Logging end of task`
    | regexp `.*Logging end of task (?P<taskName>.*) \(ID(?P<taskID>.*)\): (?P<result>.*)\r` 
    | label_format Successes=`{{ if eq .result "Success"  }}1{{ else }}0{{ end }}`
    | label_format Failures=`{{ if eq .result "Failure"  }}1{{ else }}0{{ end }}`
    | label_format Noxfers             =`{{ if eq .result "No xfers" }}1{{ else }}0{{ end }}`
    | unwrap Successes
    [$__auto]
    )) by (taskName)

You could try to join your queries in Grafana dashboard with join transformations.

I think it’s also possible to do it from query side, if you can provide some example logs I can poke at it. One thing that could help is instead of using successes and failures, turn that into just one label (maybe call it status), and have it be success or fail depending on result. That way you can sum by the label, along with task ID, which should give you one metrics series to work with.

For transforms: I’ve tried using a ‘group by’ transformation on taskId with ‘result’ for calculate, but I can’t see the counts for each result in the row.

For query: the best I came up with is the label_format idea above, but I can’t unwrap all of them.

Some example logs:

2025-03-03 12:45:32.232: $$ Logging end of task TaskName1 (ID 998938747): Success

2025-03-03 12:54:01.793: $$ Logging end of task TaskName2 (ID 996772873): No xfers

2025-03-02 17:30:35.598: $$ Logging end of task TaskName3 (ID 811665646): Failure

2025-03-02 17:30:31.598: $$ Logging end of task TaskName4 (ID 811665646): Success

2025-03-02 17:32:31.598: $$ Logging end of task TaskName1 (ID 811665646): Success

Any other ideas?