debian-mirror-gitlab/doc/user/project/insights/index.md

497 lines
13 KiB
Markdown
Raw Normal View History

2021-01-29 00:20:46 +05:30
---
2022-11-25 23:54:43 +05:30
stage: Plan
2022-10-11 01:57:18 +05:30
group: Optimize
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2021-01-29 00:20:46 +05:30
---
2022-11-25 23:54:43 +05:30
# Insights for projects **(ULTIMATE)**
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Configure project insights to explore data such as:
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
- Issues created and closed during a specified period.
- Average time for merge requests to be merged.
- Triage hygiene.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Insights are also available for [groups](../../group/insights/index.md).
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
## View project insights
2019-09-04 21:01:54 +05:30
2022-11-25 23:54:43 +05:30
Prerequisites:
2019-09-04 21:01:54 +05:30
2022-11-25 23:54:43 +05:30
- You must have:
- Access to a project to view information about its merge requests and issues.
- Permission to view confidential merge requests and issues in the project.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
To view project insights:
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
1. On the top bar, select **Main menu > Projects** and find your project.
1. On the left sidebar, select **Analytics > Insights**.
1. To view a report, select the **Select report** dropdown list.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
## Configure project insights
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Prerequisites:
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
- Depending on your project configuration, you must have at least the Developer role.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Project insights are configured with the [`.gitlab/insights.yml`](#insights-configuration-file) file in the project. If a project doesn't have a configuration file, it uses the [group configuration](../../group/insights/index.md#configure-group-insights).
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
The `.gitlab/insights.yml` file is a YAML file where you define:
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
- The structure and order of charts in a report.
- The style of charts displayed in the report of your project or group.
To configure project insights, either:
- Create a `.gitlab/insights.yml` file locally in the root directory of your project, and push your changes.
- Create a `.gitlab/insights.yml` file in the UI:
1. On the top bar, select **Main menu > Projects** and find your project.
1. Above the file list, select the branch you want to commit to, select the plus icon, then select **New file**.
1. In the **File name** text box, enter `.gitlab/insights.yml`.
1. In the large text box, update the file contents.
1. Select **Commit changes**.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
After you create the configuration file, you can also
[use it for the project's group](../../group/insights/index.md#configure-group-insights).
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
## Insights configuration file
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
In the `.gitlab/insights.yml` file:
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
- [Configuration parameters](#insights-configuration-parameters) define the chart behavior.
- Each report has a unique key and a collection of charts to fetch and display.
- Each chart definition is made up of a hash composed of key-value pairs.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
The following example shows a single definition that displays one report with one chart.
2019-07-31 22:56:46 +05:30
```yaml
bugsCharts:
2019-12-21 20:55:43 +05:30
title: "Charts for bugs"
2019-07-31 22:56:46 +05:30
charts:
2019-12-21 20:55:43 +05:30
- title: "Monthly bugs created"
2020-04-08 14:13:33 +05:30
description: "Open bugs created per month"
2019-07-31 22:56:46 +05:30
type: bar
query:
2022-08-27 11:52:29 +05:30
data_source: issuables
params:
issuable_type: issue
issuable_state: opened
filter_labels:
- bug
group_by: month
period_limit: 24
2019-07-31 22:56:46 +05:30
```
2022-11-25 23:54:43 +05:30
## Insights configuration parameters
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
The following table lists the chart parameters:
2019-07-31 22:56:46 +05:30
| Keyword | Description |
|:---------------------------------------------------|:------------|
2021-02-22 17:27:13 +05:30
| [`title`](#title) | The title of the chart. This displays on the Insights page. |
| [`description`](#description) | A description for the individual chart. This displays above the relevant chart. |
2020-03-13 15:44:24 +05:30
| [`type`](#type) | The type of chart: `bar`, `line` or `stacked-bar`. |
2022-08-27 11:52:29 +05:30
| [`query`](#query) | A hash that defines the data source and filtering conditions for the chart. |
2019-07-31 22:56:46 +05:30
### `title`
2022-11-25 23:54:43 +05:30
Use `title` to update the chart title. The title displays on the insights report.
**Example:**
2019-07-31 22:56:46 +05:30
```yaml
monthlyBugsCreated:
2019-12-21 20:55:43 +05:30
title: "Monthly bugs created"
2019-07-31 22:56:46 +05:30
```
2020-04-08 14:13:33 +05:30
### `description`
2022-11-25 23:54:43 +05:30
Use `description` to add a description of the chart. The description displays above the chart, below the title.
**Example:**
2020-04-08 14:13:33 +05:30
```yaml
monthlyBugsCreated:
title: "Monthly bugs created"
description: "Open bugs created per month"
```
2019-07-31 22:56:46 +05:30
### `type`
2022-11-25 23:54:43 +05:30
Use `type` to define the chart type.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
**Supported values:**
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
| Name | Example: |
2019-07-31 22:56:46 +05:30
| ----- | ------- |
| `bar` | ![Insights example bar chart](img/insights_example_bar_chart.png) |
2022-01-26 12:08:38 +05:30
| `bar` (time series, that is when `group_by` is used) | ![Insights example bar time series chart](img/insights_example_bar_time_series_chart.png) |
2019-07-31 22:56:46 +05:30
| `line` | ![Insights example stacked bar chart](img/insights_example_line_chart.png) |
| `stacked-bar` | ![Insights example stacked bar chart](img/insights_example_stacked_bar_chart.png) |
2022-11-25 23:54:43 +05:30
The `dora` data source supports the `bar` and `line` [chart types](#type).
**Example:**
```yaml
monthlyBugsCreated:
title: "Monthly bugs created"
type: bar
```
2022-08-27 11:52:29 +05:30
2019-07-31 22:56:46 +05:30
### `query`
2022-11-25 23:54:43 +05:30
Use `query` to define the data source and filtering conditions for the chart.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
**Example:**
2019-07-31 22:56:46 +05:30
2022-08-27 11:52:29 +05:30
```yaml
monthlyBugsCreated:
title: "Monthly bugs created"
description: "Open bugs created per month"
type: bar
query:
data_source: issuables
params:
issuable_type: issue
issuable_state: opened
filter_labels:
- bug
collection_labels:
- S1
- S2
- S3
- S4
group_by: week
period_limit: 104
```
The legacy format without the `data_source` parameter is still supported:
2019-07-31 22:56:46 +05:30
```yaml
monthlyBugsCreated:
2019-12-21 20:55:43 +05:30
title: "Monthly bugs created"
2020-04-08 14:13:33 +05:30
description: "Open bugs created per month"
2019-07-31 22:56:46 +05:30
type: bar
query:
issuable_type: issue
issuable_state: opened
filter_labels:
- bug
collection_labels:
- S1
- S2
- S3
- S4
group_by: week
period_limit: 104
```
2022-08-27 11:52:29 +05:30
#### `query.data_source`
> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/725) in GitLab 15.3.
2022-11-25 23:54:43 +05:30
Use `data_source` to define the data source that exposes the data.
2022-08-27 11:52:29 +05:30
2022-11-25 23:54:43 +05:30
**Supported values:**
2022-08-27 11:52:29 +05:30
- `issuables`: Exposes merge request or issue data.
2022-11-25 23:54:43 +05:30
- `dora`: Exposes DORA metrics.
2022-08-27 11:52:29 +05:30
2022-11-25 23:54:43 +05:30
#### `issuable` query parameters
2022-08-27 11:52:29 +05:30
##### `query.params.issuable_type`
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Use `query.params.issuable_type` to define the type of issuable to create a chart for.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
**Supported values:**
2019-07-31 22:56:46 +05:30
2021-02-22 17:27:13 +05:30
- `issue`: The chart displays issues' data.
- `merge_request`: The chart displays merge requests' data.
2019-07-31 22:56:46 +05:30
2022-08-27 11:52:29 +05:30
##### `query.params.issuable_state`
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Use `query.params.issuable_state` to filter by the current state of the queried issuable.
2019-07-31 22:56:46 +05:30
2021-02-22 17:27:13 +05:30
By default, the `opened` state filter is applied.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
**Supported values:**
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
- `opened`: Open issues or merge requests.
- `closed`: Closed issues or merge requests.
- `locked`: Issues or merge requests that have their discussion locked.
2019-07-31 22:56:46 +05:30
- `merged`: Merged merge requests.
2022-11-25 23:54:43 +05:30
- `all`: Issues or merge requests in all states.
2019-07-31 22:56:46 +05:30
2022-08-27 11:52:29 +05:30
##### `query.params.filter_labels`
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Use `query.params.filter_labels` to filter by labels applied to the queried issuable.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
By default, no label filter is applied. All defined labels must
be applied to the issuable for it to be selected.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
**Example:**:
2019-07-31 22:56:46 +05:30
```yaml
monthlyBugsCreated:
2019-12-21 20:55:43 +05:30
title: "Monthly regressions created"
2019-07-31 22:56:46 +05:30
type: bar
query:
2022-08-27 11:52:29 +05:30
data_source: issuables
params:
issuable_type: issue
issuable_state: opened
filter_labels:
- bug
- regression
2019-07-31 22:56:46 +05:30
```
2022-08-27 11:52:29 +05:30
##### `query.params.collection_labels`
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Use `query.params.collection_labels` to group issuables by the configured labels.
Grouping is not applied by default.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
When using this parameter, you must
set `type` to `line` or `stacked-bar`.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
**Example:**
2019-07-31 22:56:46 +05:30
```yaml
weeklyBugsBySeverity:
2019-12-21 20:55:43 +05:30
title: "Weekly bugs by severity"
2019-07-31 22:56:46 +05:30
type: stacked-bar
query:
2022-08-27 11:52:29 +05:30
data_source: issuables
params:
issuable_type: issue
issuable_state: opened
filter_labels:
- bug
collection_labels:
- S1
- S2
- S3
- S4
2019-07-31 22:56:46 +05:30
```
2022-08-27 11:52:29 +05:30
##### `query.group_by`
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Use `query.group_by` to define the X-axis of the chart.
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
**Supported values:**
2019-07-31 22:56:46 +05:30
- `day`: Group data per day.
- `week`: Group data per week.
- `month`: Group data per month.
2022-08-27 11:52:29 +05:30
##### `query.period_limit`
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
Use `query.period_limit` to define how far back in time to query issuables (using the `query.period_field`).
2019-07-31 22:56:46 +05:30
2022-11-25 23:54:43 +05:30
The unit is related to the value defined in `query.group_by`. For example, if you
defined `query.group_by: 'day'`, and `query.period_limit: 365`, the chart displays data from the last 365 days.
2019-07-31 22:56:46 +05:30
2021-02-22 17:27:13 +05:30
By default, default values are applied depending on the `query.group_by`
2019-07-31 22:56:46 +05:30
you defined.
| `query.group_by` | Default value |
| ---------------- | ------------- |
| `day` | 30 |
| `week` | 4 |
| `month` | 12 |
2020-07-28 23:09:34 +05:30
#### `query.period_field`
2022-11-25 23:54:43 +05:30
Use `query.period_field` to define the timestamp field by which to group issuables.
2020-07-28 23:09:34 +05:30
2022-11-25 23:54:43 +05:30
**Supported values:**
2020-07-28 23:09:34 +05:30
- `created_at` (default): Group data using the `created_at` field.
- `closed_at`: Group data using the `closed_at` field (for issues only).
- `merged_at`: Group data using the `merged_at` field (for merge requests only).
The `period_field` is automatically set to:
- `closed_at` if `query.issuable_state` is `closed`
- `merged_at` if `query.issuable_state` is `merged`
- `created_at` otherwise
2021-02-22 17:27:13 +05:30
NOTE:
Until [this bug](https://gitlab.com/gitlab-org/gitlab/-/issues/26911), is resolved,
you may see `created_at` in place of `merged_at`. `created_at` is used instead.
2020-07-28 23:09:34 +05:30
2022-08-27 11:52:29 +05:30
#### `DORA` query parameters
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/367248) in GitLab 15.3.
2022-11-25 23:54:43 +05:30
Use DORA-specific queries with the `dora` data source to create a DORA chart definition.
**Example:**
2022-08-27 11:52:29 +05:30
```yaml
dora:
title: "DORA charts"
charts:
- title: "DORA deployment frequency"
2022-10-11 01:57:18 +05:30
type: bar # or line
2022-08-27 11:52:29 +05:30
query:
data_source: dora
params:
metric: deployment_frequency
group_by: day
period_limit: 10
projects:
only:
- 38
- title: "DORA lead time for changes"
description: "DORA lead time for changes"
type: bar
query:
data_source: dora
params:
metric: lead_time_for_changes
group_by: day
environment_tiers:
- staging
period_limit: 30
```
##### `query.metric`
2022-11-25 23:54:43 +05:30
Use `query.metric` to define the [DORA metrics](../../../api/dora/metrics.md#the-value-field) to query.
**Supported values:**
2022-08-27 11:52:29 +05:30
- `deployment_frequency` (default)
- `lead_time_for_changes`
- `time_to_restore_service`
- `change_failure_rate`
##### `query.group_by`
2022-11-25 23:54:43 +05:30
Use `query.group_by` to define the X-axis of your chart.
2022-08-27 11:52:29 +05:30
2022-11-25 23:54:43 +05:30
**Supported values:**
2022-08-27 11:52:29 +05:30
- `day` (default): Group data per day.
- `month`: Group data per month.
##### `query.period_limit`
2022-11-25 23:54:43 +05:30
Use `query.period_limit` to define how far the metrics are queried in the past (default: 15). The maximum period is 180 days or 6 months.
2022-08-27 11:52:29 +05:30
##### `query.environment_tiers`
2022-11-25 23:54:43 +05:30
Use `query.environment_tiers` to define an array of environments to include the calculation.
2022-08-27 11:52:29 +05:30
2022-11-25 23:54:43 +05:30
**Supported values:**
2019-12-21 20:55:43 +05:30
2022-11-25 23:54:43 +05:30
- `production`(default)
- `staging`
- `testing`
- `development`
- `other`
### `projects`
2019-12-21 20:55:43 +05:30
2022-11-25 23:54:43 +05:30
Use `projects` to limit where issuables are queried from:
2019-12-21 20:55:43 +05:30
2022-11-25 23:54:43 +05:30
- If `.gitlab/insights.yml` is used for a [group's insights](../../group/insights/index.md#configure-group-insights), use `projects` to define the projects from which to query issuables. By default, all projects under the group are used.
- If `.gitlab/insights.yml` is used for a project's insights, specifying other projects does not yield results. By default, the project is used.
2019-12-21 20:55:43 +05:30
#### `projects.only`
2022-11-25 23:54:43 +05:30
Use `projects.only` to specify the projects from which issuables
are queried.
2019-12-21 20:55:43 +05:30
2022-11-25 23:54:43 +05:30
Projects listed in this parameter are ignored when:
2019-12-21 20:55:43 +05:30
- They don't exist.
- The current user doesn't have sufficient permissions to read them.
2022-11-25 23:54:43 +05:30
- They are outside the group.
2019-12-21 20:55:43 +05:30
2022-11-25 23:54:43 +05:30
**Example:**
2019-12-21 20:55:43 +05:30
```yaml
monthlyBugsCreated:
title: "Monthly bugs created"
2020-04-08 14:13:33 +05:30
description: "Open bugs created per month"
2019-12-21 20:55:43 +05:30
type: bar
query:
2022-08-27 11:52:29 +05:30
data_source: issuables
params:
issuable_type: issue
issuable_state: opened
filter_labels:
- bug
2019-12-21 20:55:43 +05:30
projects:
only:
- 3 # You can use the project ID
- groupA/projectA # Or full project path
- groupA/subgroupB/projectC # Projects in subgroups can be included
- groupB/project # Projects outside the group will be ignored
```
2022-11-25 23:54:43 +05:30
## Complete insights configuration example
2019-07-31 22:56:46 +05:30
```yaml
2019-12-21 20:55:43 +05:30
.projectsOnly: &projectsOnly
projects:
only:
- 3
- groupA/projectA
- groupA/subgroupB/projectC
2019-07-31 22:56:46 +05:30
bugsCharts:
2019-12-21 20:55:43 +05:30
title: "Charts for bugs"
2019-07-31 22:56:46 +05:30
charts:
2019-12-21 20:55:43 +05:30
- title: "Monthly bugs created"
2020-04-08 14:13:33 +05:30
description: "Open bugs created per month"
2019-07-31 22:56:46 +05:30
type: bar
2019-12-21 20:55:43 +05:30
<<: *projectsOnly
2019-07-31 22:56:46 +05:30
query:
2022-08-27 11:52:29 +05:30
data_source: issuables
params:
issuable_type: issue
issuable_state: opened
filter_labels:
- bug
group_by: month
period_limit: 24
2019-12-21 20:55:43 +05:30
- title: "Weekly bugs by severity"
2019-07-31 22:56:46 +05:30
type: stacked-bar
2019-12-21 20:55:43 +05:30
<<: *projectsOnly
2019-07-31 22:56:46 +05:30
query:
2022-08-27 11:52:29 +05:30
data_source: issuables
params:
issuable_type: issue
issuable_state: opened
filter_labels:
- bug
collection_labels:
- S1
- S2
- S3
- S4
group_by: week
period_limit: 104
2019-12-21 20:55:43 +05:30
- title: "Monthly bugs by team"
2019-07-31 22:56:46 +05:30
type: line
2019-12-21 20:55:43 +05:30
<<: *projectsOnly
2019-07-31 22:56:46 +05:30
query:
2022-08-27 11:52:29 +05:30
data_source: issuables
params:
issuable_type: merge_request
issuable_state: opened
filter_labels:
- bug
collection_labels:
- Manage
- Plan
- Create
group_by: month
period_limit: 24
2019-07-31 22:56:46 +05:30
```