API: Provide a simple interface of pending jobs for a given runner group
When implementing CI/CD pipelines in gitlab it is useful to know how many jobs are queued for a given group of workers. This data would be useful for:
- Monitoring
- Usage reporting
- Autoscaling
Currently there does not appear to be any API that allows this. The /runner/ api does not return pending jobs a runner could take, only jobs it has taken. The /jobs/ endpoint requires iterating over each possible project, which is onerous in large organizations with thousands of projects and made worse by the fact that the /projects/ endpoint returns public projects without careful filtering.
This may be possible with the fleeting system, but that seems to be focused to a fault on managing individual instances; I don't see any hooks to get metrics out of it.
Similar asks pop up on the internet: https://forum.gitlab.com/t/using-gitlab-api-to-find-all-current-pending-jobs-across-all-projects/57129
Please add an API for this. Thank you.