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 |
|---|---|
|
|
| Usage |
|---|
![]() |
| Viewport size | After |
|---|---|
xs (<576px) |
|
sm (>=576px) |
|
How to set up and validate locally
You'll need a project with CI enabled and a GitLab instance with clickhouse enabled.
- Visit you project's homepage, in my case it is: http://gdk.test:3000/my-group/my-project, and note the project ID
- Go to the rails console by typing
bundle exec rails c - Enable the feature flag
Feature.enable(:ci_improved_project_pipeline_analytics) - 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
- 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




