debian-mirror-gitlab/doc/api/dora/metrics.md

111 lines
5.5 KiB
Markdown
Raw Normal View History

2021-04-29 21:17:54 +05:30
---
2022-11-25 23:54:43 +05:30
stage: Plan
2021-11-18 22:05:49 +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-04-29 21:17:54 +05:30
type: reference, api
---
# DevOps Research and Assessment (DORA) key metrics API **(ULTIMATE)**
2021-11-11 11:23:49 +05:30
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/279039) in GitLab 13.10.
2021-09-04 01:27:46 +05:30
> - The legacy key/value pair `{ "<date>" => "<value>" }` was removed from the payload in GitLab 14.0.
2022-05-07 20:08:51 +05:30
> `time_to_restore_service` metric was introduced in GitLab 14.9.
2021-04-29 21:17:54 +05:30
2023-07-09 08:55:56 +05:30
You can also retrieve [DORA metrics](../../user/analytics/dora_metrics.md) with the [GraphQL API](../../api/graphql/reference/index.md).
2023-06-20 00:43:36 +05:30
2022-04-04 11:22:00 +05:30
All methods require at least the Reporter role.
2021-04-29 21:17:54 +05:30
## Get project-level DORA metrics
Get project-level DORA metrics.
```plaintext
GET /projects/:id/dora/metrics
```
2022-08-13 15:12:31 +05:30
| Attribute | Type | Required | Description |
|:---------------------|:-----------------|:---------|:------------|
2023-04-23 21:23:45 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](../rest/index.md#namespaced-path-encoding) can be accessed by the authenticated user. |
2022-08-13 15:12:31 +05:30
| `metric` | string | yes | One of `deployment_frequency`, `lead_time_for_changes`, `time_to_restore_service` or `change_failure_rate`. |
| `end_date` | string | no | Date range to end at. ISO 8601 Date format, for example `2021-03-01`. Default is the current date. |
| `environment_tiers` | array of strings | no | The [tiers of the environments](../../ci/environments/index.md#deployment-tier-of-environments). Default is `production`. |
| `interval` | string | no | The bucketing interval. One of `all`, `monthly` or `daily`. Default is `daily`. |
| `start_date` | string | no | Date range to start from. ISO 8601 Date format, for example `2021-03-01`. Default is 3 months ago. |
2021-04-29 21:17:54 +05:30
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/dora/metrics?metric=deployment_frequency"
```
Example response:
```json
[
2021-09-04 01:27:46 +05:30
{ "date": "2021-03-01", "value": 3 },
{ "date": "2021-03-02", "value": 6 },
{ "date": "2021-03-03", "value": 0 },
{ "date": "2021-03-04", "value": 0 },
{ "date": "2021-03-05", "value": 0 },
{ "date": "2021-03-06", "value": 0 },
{ "date": "2021-03-07", "value": 0 },
{ "date": "2021-03-08", "value": 4 }
2021-04-29 21:17:54 +05:30
]
```
## Get group-level DORA metrics
2021-11-11 11:23:49 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/279039) in GitLab 13.10.
2021-04-29 21:17:54 +05:30
Get group-level DORA metrics.
```plaintext
GET /groups/:id/dora/metrics
```
2022-08-13 15:12:31 +05:30
| Attribute | Type | Required | Description |
|:--------------------|:-----------------|:---------|:------------|
2023-04-23 21:23:45 +05:30
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](../rest/index.md#namespaced-path-encoding) can be accessed by the authenticated user. |
2022-08-13 15:12:31 +05:30
| `metric` | string | yes | One of `deployment_frequency`, `lead_time_for_changes`, `time_to_restore_service` or `change_failure_rate`. |
| `end_date` | string | no | Date range to end at. ISO 8601 Date format, for example `2021-03-01`. Default is the current date. |
| `environment_tiers` | array of strings | no | The [tiers of the environments](../../ci/environments/index.md#deployment-tier-of-environments). Default is `production`. |
| `interval` | string | no | The bucketing interval. One of `all`, `monthly` or `daily`. Default is `daily`. |
| `start_date` | string | no | Date range to start from. ISO 8601 Date format, for example `2021-03-01`. Default is 3 months ago. |
2021-04-29 21:17:54 +05:30
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/dora/metrics?metric=deployment_frequency"
```
Example response:
```json
[
2021-09-04 01:27:46 +05:30
{ "date": "2021-03-01", "value": 3 },
{ "date": "2021-03-02", "value": 6 },
{ "date": "2021-03-03", "value": 0 },
{ "date": "2021-03-04", "value": 0 },
{ "date": "2021-03-05", "value": 0 },
{ "date": "2021-03-06", "value": 0 },
{ "date": "2021-03-07", "value": 0 },
{ "date": "2021-03-08", "value": 4 }
2021-04-29 21:17:54 +05:30
]
```
## The `value` field
For both the project and group-level endpoints above, the `value` field in the
API response has a different meaning depending on the provided `metric` query
parameter:
2022-08-13 15:12:31 +05:30
| `metric` query parameter | Description of `value` in response |
|:---------------------------|:-----------------------------------|
2023-05-27 22:25:52 +05:30
| `deployment_frequency` | The API returns the total number of successful deployments during the time period. [Issue 371271](https://gitlab.com/gitlab-org/gitlab/-/issues/371271) proposes to update the API to return the daily average instead of the total number. |
2022-08-13 15:12:31 +05:30
| `change_failure_rate` | The number of incidents divided by the number of deployments during the time period. Available only for production environment. |
2023-03-04 22:38:38 +05:30
| `lead_time_for_changes` | The median number of seconds between the merge of the merge request (MR) and the deployment of the MR commits for all MRs deployed during the time period. |
2022-08-13 15:12:31 +05:30
| `time_to_restore_service` | The median number of seconds an incident was open during the time period. Available only for production environment. |
2022-10-11 01:57:18 +05:30
NOTE:
The API returns the `monthly` and `all` intervals by calculating the median of the daily median values. This can introduce a slight inaccuracy in the returned data.