Add aggregated metric information to metrics yaml
What does this MR do and why?
Implements #373830 (closed)
It adds support for metric aggregation feature definitions to be included into metric YAML definition. This is first iteration, that only allows to add the same configuration pieces into metrics YAML definition as there are config/metrics/aggregates/*.yaml
, but those information is not yet used in code. That would be implemented in follow up #370963 (closed)
Why it is needed
Because Redis metric aggregation feature was created before merics yml definitions
and this caused legacy duplication and distribution of information. Event can be aggregated into metric with 3 of following ways:
- Total metrics - already deprecated feature, yet still used by some older metrics
- Aggregated metrics - via yaml config files at https://gitlab.com/gitlab-org/gitlab/-/tree/master/config/metrics/aggregates and https://gitlab.com/gitlab-org/gitlab/-/tree/master/ee/config/metrics/aggregates
- Metric yaml deifnition - via
option.events
This makes create confusing experience for developers, and makes it harder to utilize aggregation information for any downstream systems as discussed at #370462 (comment 1067324388)
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
This MR includes one metric YAML definition that is already modified to check MR changes on CI.
To test MR changes in rails console change any metric YAML definition and load all metrics YAML definitions, which also performs validation against schema. If changes are compliant definitions would be loaded, and if not error would be raised
[5] pry(main)> Gitlab::Usage::MetricDefinition.definitions
=> {"usage_activity_by_stage.manage.ldap_group_sync_enabled"=>
#<Gitlab::Usage::MetricDefinition:0x00007f8be6b8d570
@attributes=
{:data_category=>"optional",
:key_path=>"usage_activity_by_stage.manage.ldap_group_sync_enabled",
:description=>"Has the instance configured [LDAP Group Sync](https://docs.gitlab.com/ee/administration/auth/ldap/#group-sync)",
:product_section=>"dev",
:product_stage=>"manage",
:product_group=>"authentication_and_authorization",
:product_category=>"authentication_and_authorization",
:value_type=>"boolean",
:status=>"active",
:time_frame=>"none",
:data_source=>"system",
:distribution=>["ee"],
:tier=>["premium", "ultimate"],
:performance_indicator_type=>[],
:milestone=>"<13.9"},
@path="/Users/mikolajwawrzyniak/gitlab/gitlab-development-kit/gitlab/ee/config/metrics/settings/20210216180809_ldap_group_sync_enabled.yml">,
"usage_activity_by_stage.manage.group_saml_enabled"=>
#<Gitlab::Usage::MetricDefinition:0x00007f8be6b67668
@attributes=
{:data_category=>"operational",
:key_path=>"usage_activity_by_stage.manage.group_saml_enabled",
:description=>"Has the instance enabled Group SAML SSO `https://docs.gitlab.com/ee/user/group/saml_sso/` on at least 1 group?",
:product_section=>"dev",
:product_stage=>"manage",
:product_group=>"manage",
:product_category=>nil,
:value_type=>"boolean",
:status=>"active",
:time_frame=>"none",
:data_source=>"system",
:distribution=>["ee"],
:tier=>["premium", "ultimate"],
:performance_indicator_type=>[],
:milestone=>"<13.9"},
@path="/Users/mikolajwawrzyniak/gitlab/gitlab-development-kit/gitlab/ee/config/metrics/settings/20210216180813_group_saml_enabled.yml">,
[7] pry(main)> Gitlab::Usage::MetricDefinition.definitions
Gitlab::Usage::MetricDefinition::InvalidError: Error type: enum
Data: rediz
Path: /options/aggregate/source
Details:
Metric file: /Users/mikolajwawrzyniak/gitlab/gitlab-development-kit/gitlab/config/metrics/counts_28d/20210216180509_incident_management_alerts_total_unique_counts.yml
from /Users/mikolajwawrzyniak/gitlab/gitlab-development-kit/gitlab/lib/gitlab/error_tracking.rb:95:in `track_and_raise_for_dev_exception'
Caused by Gitlab::Usage::MetricDefinition::InvalidError: Error type: enum
Data: rediz
Path: /options/aggregate/source
Details:
Metric file: /Users/mikolajwawrzyniak/gitlab/gitlab-development-kit/gitlab/config/metrics/counts_28d/20210216180509_incident_management_alerts_total_unique_counts.yml
from /Users/mikolajwawrzyniak/gitlab/gitlab-development-kit/gitlab/lib/gitlab/error_tracking.rb:95:in `track_and_raise_for_dev_exception'
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.