GitLab Duo
This guide explains how to upload GitLab Duo usage metrics into DX using a CSV file. Once an API is made available by GitLab, this process will be automated through a DX data connector.
Prerequisites
- GitLab Duo access
- a DX database user with write access
Setup instructions
Follow the steps below to import GitLab Duo data into DX.
Step 1– Create custom table
To import GitLab Duo usage metrics into DX, you’ll first need to create a custom table in your DX database.
- Use a Postgres client (Postico or pgAdmin) to connect to your DX database.
- Then, execute the SQL statement below:
CREATE TABLE custom.gitlab_duo_daily_usages (
id SERIAL PRIMARY KEY,
date DATE NOT NULL,
email CHARACTER VARYING(256),
is_active BOOLEAN NOT NULL,
total_accepts INTEGER,
total_rejects INTEGER,
chat_requests INTEGER
);
Step 2- Export GitLab Duo data
Download a CSV export of your GitLab Duo telemtry data.
Step 3- Format GitLab Duo data
Download a raw export of your GitLab Duo usage metrics and update the CSV file to match the schema in Step 1. Ensure the data includes:
date– the date of usage activityemail– user’s email addressis_active– boolean indicating if the user was active on that date
Step 4- Import GitLab Duo data
Use the Import CSV feature in Postico or pgAdmin to upload your data to DX.
- Right-click the
custom.gitlab_duo_daily_usagestable and click Import CSV - Select the formatted CSV from Step 3
- Ensure “First row is header” is checked
- Click Import
Step 5- View reports
Once your data is uploaded, use DX’s prebuilt reports or use Data Studio to create custom reports. The example query below joins GitLab Duo data and DX data, displaying GitLab Duo daily usage alongside PR throughput.
SELECT
du.name,
du.email,
COUNT(DISTINCT pr.id) AS number_of_prs_merged,
COUNT(DISTINCT aqu.date) FILTER (
WHERE aqu.is_active = true
) AS gitlab_duo_days_active
FROM dx_users du
LEFT JOIN custom.gitlab_duo_daily_usages aqu
ON LOWER(du.email) = LOWER(aqu.email)
LEFT JOIN pull_requests pr
ON pr.dx_user_id = du.id AND pr.merged >= CURRENT_DATE - INTERVAL '30 days'
WHERE
aqu.date >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY du.name, du.email;