Skip to content

Adds chart with wait time of last 3 hours

Miguel Rincon requested to merge 411966-wait-time-3-hours into master

What does this MR do and why?

Adds chart with wait time of last 3 hours

This change adds a new chart that displays the last three hours of job queue times for instance runners in the admin area.

Screenshots or screen recordings

Before After
image image
tooltip empty state
image empty

How to set up and validate locally

Preparation

We will need: 1) local ClickHouse DB, 2) configure our GDK to connect to ClickHouse and 3) Add test data

Local ClickHouse

  1. Follow the instructions to install here: https://clickhouse.com/docs/en/install#quick-install

  2. Connect to the client create two databases:

$ ./clickhouse client
:) create database gitlab_clickhouse_test;
:) create database gitlab_clickhouse_development;
  1. In the rails console, rails c, run:
> require_relative 'spec/support/database/click_house/hooks.rb'
> ClickHouseTestRunner.new.ensure_schema
Click to expand image

Configure GDK to connect

  1. Create a file in our gitlab directory called: config/click_house.yml, add the following:
test:
  main:
    database: gitlab_clickhouse_test
    url: 'http://localhost:8123'
    username: default
development:
  main:
    database: gitlab_clickhouse_development
    url: 'http://localhost:8123'
    username: default
  1. gdk restart so the configuration is loaded

Add test data

  1. Connect to the client and paste the following:
$ ./clickhouse client -d gitlab_clickhouse_development
mrincon-laptop.local :) INSERT INTO ci_finished_builds
    (id, project_id, pipeline_id, status, finished_at, created_at, started_at, queued_at,
     runner_id, runner_manager_system_xid, runner_run_untagged, runner_type,
     runner_manager_version, runner_manager_revision, runner_manager_platform, runner_manager_architecture)
SELECT
    number AS id,
    toUInt64(1 * pow(1 - (rand() / 4294967295.0), -1/1.0)) AS project_id,
    toUInt64(1 * pow(1 - (rand() / 4294967295.0), -1/1.0)) AS pipeline_id,
    arrayElement(['success', 'success', 'success', 'success', 'success', 'failed', 'failed', 'cancelled'], 1 + (rand() % 8)) AS status,
    (now() - toIntervalSecond(rand() % (86400 * 30))) AS finished_at,
    (finished_at - toIntervalSecond(-600 * ln(1 - rand() / 4294967295.0))) AS started_at,
    (started_at - toIntervalSecond(-10 * ln(1 - rand() / 4294967295.0))) AS queued_at,
    (queued_at - toIntervalSecond(-10 * ln(1 - rand() / 4294967295.0))) AS created_at,
    rand() % 10000 AS runner_id,
    toString(rand() % 1000) AS runner_manager_system_xid,
    rand() % 2 AS runner_run_untagged,
    rand() % 3 + 1 AS runner_type,
    '' AS runner_manager_version,
    '' AS runner_manager_revision,
    '' AS runner_manager_platform,
    '' AS runner_manager_architecture
FROM numbers(300000);
Click to expand image

Validation

  1. Login as admin user to your GDK
  2. Enable Feature.enable(:clickhouse_ci_analytics) and Feature.enable(:runners_dashboard)
  3. Visit http://gdk.test:3000/admin/runners/dashboard

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #411966 (closed)

Edited by Miguel Rincon

Merge request reports