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)