Skip to content

Adds branch filter to CI/CD analytics dashboard

What does this MR do and why?

Adds branch filter

When reviewing pipeline metrics in a project, users can filter by branch to allow you to see metrics for pipelines run for a specific branch.

References

Screenshots or screen recordings

Before After
image image
Usage
2025-03-20_15.32.53
Viewport size After
xs (<576px) image
sm (>=576px) image

How to set up and validate locally

You'll need a project with CI enabled and a GitLab instance with clickhouse enabled.

  1. Visit you project's homepage, in my case it is: http://gdk.test:3000/my-group/my-project, and note the project ID
  2. Go to the rails console by typing bundle exec rails c
  3. Enable the feature flag Feature.enable(:ci_improved_project_pipeline_analytics)
  4. We want to simulate having run many pipelines. I've created a script which we can use in the rails console.

Copy the following into the console:

def seed_pipeline_analytics(project_id, from_days, pipeline_count)
  traversal_path = Project.find(project_id).project_namespace.traversal_path

  rand_status = -> { ['success', 'success', 'failed', 'failed', 'canceled'].sample }
  rand_date = -> { (rand((Time.now - 60 * 60 * 24 * from_days)..Time.now)).strftime('%F %T') }
  rand_duration = -> { rand(60) + rand(60) + rand(60) + rand(60) + rand(60) }
  rand_source = -> { ['push', 'push', 'web' ].sample }
  rand_ref = -> { ['main', 'main', nil ].sample }

  sample_data = []
  pipeline_count.times {|i| sample_data.push({
    id: sample_data.length,
    path: traversal_path,
    status: rand_status.call,
    started_at: rand_date.call,
    duration: rand_duration.call,
    source: rand_source.call,
    ref: rand_ref.call })
  }

  sample_data.each do |record|
    query = <<-SQL
      INSERT INTO ci_finished_pipelines 
      (id, path, status, started_at, duration, source, ref)
      VALUES (#{record[:id]}, '#{record[:path]}', '#{record[:status]}', '#{record[:started_at]}', '#{record[:duration]}', '#{record[:source]}', '#{record[:ref]}')
    SQL
    ClickHouse::Client.execute(query, :main)
  end
end
seed_pipeline_analytics(22, 7, 100) # project id, one week of activity to simulate, number of pipelines to simulate
  1. Visit your project's CI/CD dashboard at "Analyze > CI/CD Analytics" to see the changes:

Example URL: http://gdk.test:3000/my-group/my-project/-/pipelines/charts

MR acceptance checklist

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

Related to #469599 (closed)

Edited by Miguel Rincon

Merge request reports

Loading