How to apply the same alarm rule to multiple jobs

We have multiple jobs in a dashboard. Is there a way to create a alarm rule that evaluates each job individually?
Now, the query I set:

topk(10, max by(COMMAND) (max_over_time({job="6116"} |= `root` |= `%` != `Mem` | regexp `\[(?P<time>\d+-\d+-\d+ \d+:\d+:\d+)\]\s+(?P<PID>\d+)\s+(?P<PPID>\d+)\s+(?P<USER>root)\s+(?P<STAT>[A-Z]+)\s*\S*\s*(?P<VSZ>\w+)\s+(?P<percent_VSZ>\d+)%\s+(?P<percent_CPU>\d+)%\s+(?P<COMMAND>[^\r:]+)` | unwrap percent_CPU [10m])))

it can only match job named “6116”,how can I modify it?

If you want to match multiple jobs, can you try : job=~"6116|6117|6118"

Is there a way to match jobs automatically? because the name and number of the jobs are not sure.

You can try job=~"61.*" or any regex you need to match it.

I’m not sure what your query does, but I think you can try job!="" to select all jobs as well.

Thank you for your reply

1 Like