Co-authored-by: Luke Engle <99493186+luke-engle@users.noreply.github.com>
6.9 KiB
Forecast the usage of a GitLab namespace
In this lab we will use the forecast command to forecast potential GitHub Actions usage by computing metrics from the historical pipeline data in our GitLab instance. The metrics will be stored on disk in a markdown file and include job metrics for execution time, queue time, and concurrency. We will look at each of these metrics in more depth later in this lab.
- Prerequisites
- Prepare for forecast
- Perform a forecast
- Review forecast report
- Review additional files
Prerequisites
- Followed steps to set up your codespace environment.
- Completed the configure lab.
- Ran the setup script in the terminal to make sure the GitLab instance is ready.
source gitlab/bootstrap/setup.sh
Prepare for forecast
Before we can run the forecast we need to answer a few questions so we can construct the correct command.
- What namespace do we want to run the forecast for? valet. This is the only group in the demo GitLab instance.
- What is the date we want to start forecasting from? 2022-08-02. This date is before the time the data was populated on our demo GitLab instance. In practice, this should be a date that will give you enough data to get a good understanding of the typical usage. Too little data and the metrics might not give an accurate picture
- Where do we want to store the results? ./tmp/forecast_reports. This can be any valid path on the system, but for simplicity it is recommend to use a directory in the root of the codespace workspace.
Perform a forecast
- Using the answers above we get the following
forecastcommand:
gh valet forecast gitlab --output-dir ./tmp/forecast_reports --namespace valet --start-date 2022-08-02
Review forecast report
Open the forecast report and review the calculated metrics.
-
From the codespace explorer pane find
./tmp/forecast_reports/forecast_report.mdand right-click, and select Open Preview.
-
The file should be similar to this.
example forecast_report.md
Forecast report for GitLab
- Valet version: 0.1.0.13432(03b5bc9370a8f0073c0cc1a4b25f6b81d0005c0f)
- Performed at: 8/17/22 at 20:00
- Date range: 2/8/22 - 8/17/22
Total
-
Job count: 57
-
Pipeline count: 15
-
Execution time
- Total: 135 minutes
- Median: 0 minutes
- P90: 7 minutes
- Min: 0 minutes
- Max: 10 minutes
-
Queue time
- Median: 0 minutes
- P90: 5 minutes
- Min: 0 minutes
- Max: 42 minutes
-
Concurrent jobs
- Median: 0
- P90: 0
- Min: 0
- Max: 9
gitlab-runner
-
Job count: 57
-
Pipeline count: 15
-
Execution time
- Total: 135 minutes
- Median: 0 minutes
- P90: 7 minutes
- Min: 0 minutes
- Max: 10 minutes
-
Queue time
- Median: 0 minutes
- P90: 5 minutes
- Min: 0 minutes
- Max: 42 minutes
-
Concurrent jobs
- Median: 0
- P90: 0
- Min: 0
- Max: 9
Note: Concurrent jobs are calculated by using a sliding window of 1m 0s.
Metric Definitions
| Name | Description |
|---|---|
| Median | The middle value |
| P90 | 90% of the values are less than or equal too |
| Min | The lowest value |
| Max | The highest value |
Total Section
-
This section shows the metrics for all of the jobs run in projects contained in the
valetgroup, from 08/02/2022 to the time the command was executed.Total
- Job count: 57
- Pipeline count: 15
We can see we ran 15 pipelines that contained 57 jobs. The number of jobs is expected to be larger than pipelines because a pipeline is typically a collection of jobs. For example
basic-pipeline-examplecontains 6 jobs
-
Execution timeshows the metrics for the time a job took to run. Looking closer we can see during our forecast timeframe the total job run time was 135 minutes with 90% of the jobs finishing under 7 minutes, and the longest job taking 10 minutes. Theminis 0 because the quickest job took less than a minute and was rounded down to 0.- Execution time
- Total: 135 minutes
- Median: 0 minutes
- P90: 7 minutes
- Min: 0 minutes
- Max: 10 minutes
- Execution time
-
Queue timeshows the metrics for how long jobs waited for a runner to be available.- Queue time
- Median: 0 minutes
- P90: 5 minutes
- Min: 0 minutes
- Max: 42 minutes
- Queue time
-
Concurrent jobsshow the metrics for how many jobs were run at the same time.- Concurrent jobs
- Median: 0
- P90: 0
- Min: 0
- Max: 9
- Concurrent jobs
Runner Group Sections
-
The preceding section show the same metrics as the
Totalsection, but are grouped by runner group -
In this case we only have one runner group
gitlab-runnerso the metrics match theTotalsection. If there were different groups we could possibly identify runner types that needed to be increased or decreased when moving to GitHub Actionsgitlab-runner
-
Job count: 57
-
Pipeline count: 15
-
Execution time
- Total: 135 minutes
- Median: 0 minutes
- P90: 7 minutes
- Min: 0 minutes
- Max: 10 minutes
-
Queue time
- Median: 0 minutes
- P90: 5 minutes
- Min: 0 minutes
- Max: 42 minutes
-
Concurrent jobs
- Median: 0
- P90: 0
- Min: 0
- Max: 9
-
Review additional files
When Valet performs a forecast the main file of interest is the forecast_report.md but there are some additional files created in the results directory, that might help if troubleshooting is needed. In the jobs directory a .json file was created. This file is a simple JSON file containing the job objects retrieved from the GitLab instance. This file is generally not something you would look at but if you thought you were missing a particular job or jobs in the metrics, you could look here and confirm. Valet also generates logs and writes them to the log directory. Again, this is not something you would typically look at but might be useful to know.
