debian-mirror-gitlab/doc/development/usage_ping/metrics_dictionary.md

94 lines
4.3 KiB
Markdown
Raw Normal View History

2021-03-08 18:12:59 +05:30
---
stage: Growth
group: Product Intelligence
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# Metrics Dictionary Guide
This guide describes Metrics Dictionary and how it's implemented
## Metrics Definition and validation
We are using [JSON Schema](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/schema.json) to validate the metrics definition.
This process is meant to ensure consistent and valid metrics defined for Usage Ping. All metrics *must*:
2021-03-11 19:13:27 +05:30
- Comply with the defined [JSON schema](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/schema.json).
- Have a unique `key_path` .
2021-03-08 18:12:59 +05:30
- Have an owner.
All metrics are stored in YAML files:
- [`config/metrics`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/config/metrics)
2021-03-11 19:13:27 +05:30
Each metric is defined in a separate YAML file consisting of a number of fields:
2021-03-08 18:12:59 +05:30
| Field | Required | Additional information |
|---------------------|----------|----------------------------------------------------------------|
2021-03-11 19:13:27 +05:30
| `key_path` | yes | JSON key path for the metric, location in Usage Ping payload. |
2021-03-08 18:12:59 +05:30
| `description` | yes | |
| `value_type` | yes | |
| `status` | yes | |
2021-03-11 19:13:27 +05:30
| `product_group` | yes | The [group](https://about.gitlab.com/handbook/product/categories/#devops-stages) that owns the metric. |
2021-03-08 18:12:59 +05:30
| `time_frame` | yes | `string`; may be set to a value like "7d" |
| `data_source` | yes | `string`: may be set to a value like `database` or `redis_hll`. |
| `distribution` | yes | The [distribution](https://about.gitlab.com/handbook/marketing/strategic-marketing/tiers/#definitions) where the metric applies. |
| `tier` | yes | The [tier]( https://about.gitlab.com/handbook/marketing/strategic-marketing/tiers/) where the metric applies. |
| `product_category` | no | The [product category](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/categories.yml) for the metric. |
2021-03-11 19:13:27 +05:30
| `product_stage` | no | The [stage](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/stages.yml) for the metric. |
2021-03-08 18:12:59 +05:30
| `milestone` | no | The milestone when the metric is introduced. |
| `milestone_removed` | no | The milestone when the metric is removed. |
| `introduced_by_url` | no | The URL to the Merge Request that introduced the metric. |
### Example metric definition
The linked [`uuid`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/license/uuid.yml)
YAML file includes an example metric definition, where the `uuid` metric is the GitLab
instance unique identifier.
```yaml
2021-03-11 19:13:27 +05:30
key_path: uuid
2021-03-08 18:12:59 +05:30
description: GitLab instance unique identifier
value_type: string
product_category: collection
2021-03-11 19:13:27 +05:30
product_stage: growth
2021-03-08 18:12:59 +05:30
status: data_available
milestone: 9.1
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/1521
2021-03-11 19:13:27 +05:30
product_group: group::product intelligence
2021-03-08 18:12:59 +05:30
time_frame: none
data_source: database
2021-03-11 19:13:27 +05:30
distribution:
- ee
- ce
tier:
- free
- premium
- ultimate
```
## Create a new metric definition
The GitLab codebase provides a dedicated [generator](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/generators/gitlab/usage_metric_definition_generator.rb) to create new metric definitions.
For uniqueness, the generated file includes a timestamp prefix, in ISO 8601 format.
The generator takes the key path argument and 2 options and creates the metric YAML definition in corresponding location:
- `--ee`, `--no-ee` Indicates if metric is for EE.
- `--dir=DIR` indicates the metric directory. It must be one of: `counts_7d`, `7d`, `counts_28d`, `28d`, `counts_all`, `all`, `settings`, `license`.
```shell
bundle exec rails generate gitlab:usage_metric_definition counts.issues --dir=7d
create config/metrics/counts_7d/issues.yml
```
NOTE:
To create a metric definition used in EE, add the `--ee` flag.
```shell
bundle exec rails generate gitlab:usage_metric_definition counts.issues --ee --dir=7d
create ee/config/metrics/counts_7d/issues.yml
2021-03-08 18:12:59 +05:30
```