Skip to content

Add API to fetch filters for dedicated hosted runner usages

What does this MR do and why?

This merge request introduces new functionality to filter and retrieve dedicated runner usage data in GitLab. It adds a new GraphQL field ciDedicatedHostedRunnerFilters that returns filters for dedicated runner usage, including a list of distinct runners and years.

The changes also include updates to the CiRunnersFinder to support filtering by runner IDs, and new scopes in the GitlabHostedRunnerMonthlyUsage model to fetch distinct runner IDs and years.

These changes aim to improve the ability to analyze and filter runner usage data, particularly for GitLab Dedicated instances.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Query plans

Since this API is Dedicated specific, the data in production tables for .com is empty, but I still want to share the query plans for database review. I added around 500k rows to this table and generated the below query plans.

Screenshots or screen recordings

Screenshot_2025-02-18_at_3.35.58_PM

How to set up and validate locally

  1. Create some usage entries by using the below rails console command for different/same runners and different/same years.
Ci::Minutes::GitlabHostedRunnerMonthlyUsage.create!(
  billing_month: Date.new(2025, 2, 1),
  compute_minutes_used: 100.0, # Replace with the desired value
  runner_duration_seconds: 6000, # Replace with the desired value
  root_namespace: Namespace.first, # Replace with the desired namespace
  runner: Ci::Runner.first, # Replace with the desired runner
  project: Project.first # Replace with the desired project
)
  1. Enable GitLab dedicated setting with - Gitlab::CurrentSettings.update(gitlab_dedicated_instance: true)

  2. Use the below query as per filters in screenshots -

query {
  ciDedicatedHostedRunnerFilters {
    runners {
      nodes {
        id
        createdBy {
          name
        }
        runnerType
        description
        adminUrl
      }
    }
    years
  }
}
Edited by Rajendra Kadam

Merge request reports

Loading