Commit c75e2c57 authored by alinamihaila's avatar alinamihaila

Add metric to service ping if has defintion

  - Add user_auth_by_provider metric definition
  as object with related json schema
  - Remove individual metrics definitions for
  user_auth_by_provider
  - This fixes user_auth_by_provider, topology
  and projects_with_enabled_alert_integrations_histogram.
  This metrics are now added to service ping payload.
  - Add tests for object metrics
  - A hash could be a metric, with this MR
  we change th meaning of a leaf in payload.
  - A metric is a leaf if it has a metric defintion

Changelog: fixed
parent 965f3099
---
data_category: optional
key_path: usage_activity_by_stage_monthly.manage.user_auth_by_provider.two-factor-via-u2f-device
description: Number of unique user logins using two factor via a U2F device
product_section: dev
product_stage: manage
product_group: group::access
product_category: authentication_and_authorization
value_type: number
status: active
time_frame: 28d
data_source: database
distribution:
- ce
tier:
- free
- premium
- ultimate
milestone: "<13.9"
---
data_category: optional
key_path: usage_activity_by_stage_monthly.manage.user_auth_by_provider.two-factor-via-webauthn-device
description: Number of unique user logins using two factor via a WebAuthn device
product_section: dev
product_stage: manage
product_group: group::access
product_category: authentication_and_authorization
value_type: number
status: active
time_frame: 28d
data_source: database
distribution:
- ce
tier:
- free
- premium
- ultimate
milestone: "<13.9"
---
data_category: optional
key_path: usage_activity_by_stage_monthly.manage.user_auth_by_provider.standard
description: Number of unique user logins using password authentication
product_section: dev
product_stage: manage
product_group: group::access
product_category: authentication_and_authorization
value_type: number
status: active
time_frame: 28d
data_source: database
distribution:
- ce
tier:
- free
- premium
- ultimate
performance_indicator_type: []
milestone: "<13.9"
---
data_category: optional
key_path: usage_activity_by_stage_monthly.manage.user_auth_by_provider.google_oauth2
description: Number of unique user logins using Google OAuth authentication
product_section: dev
product_stage: manage
product_group: group::access
product_category: authentication_and_authorization
value_type: number
status: active
time_frame: 28d
data_source: database
distribution:
- ce
tier:
- free
- premium
- ultimate
performance_indicator_type: []
milestone: "<13.9"
--- ---
data_category: optional key_path: usage_activity_by_stage_monthly.manage.user_auth_by_provider
key_path: usage_activity_by_stage_monthly.manage.user_auth_by_provider.two-factor name: count_distinct_users_using_two_factor_authentication
description: Number of unique user logins using two factor authentication description: Number of unique user logins using two factor authentication for available providers
product_section: dev product_section: dev
product_stage: manage product_stage: manage
product_group: group::access product_group: group::access
product_category: authentication_and_authorization product_category: authentication_and_authorization
value_type: number value_type: object
status: active status: active
milestone: "14.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70061
time_frame: 28d time_frame: 28d
data_source: database data_source: database
data_category: optional
performance_indicator_type: []
distribution: distribution:
- ce - ce
- ee
tier: tier:
- free - free
- premium - premium
- ultimate - ultimate
milestone: "<13.9" value_json_schema: "config/metrics/objects_schemas/user_auth_by_provider.json"
---
data_category: optional
key_path: usage_activity_by_stage.manage.user_auth_by_provider.two-factor-via-u2f-device
description: Number of unique user logins using two factor via a U2F device
product_section: dev
product_stage: manage
product_group: group::access
product_category: authentication_and_authorization
value_type: number
status: active
time_frame: all
data_source: database
distribution:
- ce
tier:
- free
- premium
- ultimate
milestone: "<13.9"
---
data_category: optional
key_path: usage_activity_by_stage.manage.user_auth_by_provider.two-factor-via-webauthn-device
description: Number of unique user logins using two factor via a WebAuthn device
product_section: dev
product_stage: manage
product_group: group::access
product_category: authentication_and_authorization
value_type: number
status: active
time_frame: all
data_source: database
distribution:
- ce
tier:
- free
- premium
- ultimate
milestone: "<13.9"
---
data_category: optional
key_path: usage_activity_by_stage.manage.user_auth_by_provider.standard
description: Number of unique user logins using password authentication
product_section: dev
product_stage: manage
product_group: group::access
product_category: authentication_and_authorization
value_type: number
status: active
time_frame: all
data_source: database
distribution:
- ce
tier:
- free
- premium
- ultimate
milestone: "<13.9"
---
data_category: optional
key_path: usage_activity_by_stage.manage.user_auth_by_provider.google_oauth2
description: Number of unique user logins using Google OAuth authentication
product_section: dev
product_stage: manage
product_group: group::access
product_category: authentication_and_authorization
value_type: number
status: active
time_frame: all
data_source: database
distribution:
- ce
tier:
- free
- premium
- ultimate
milestone: "<13.9"
--- ---
data_category: optional key_path: usage_activity_by_stage.manage.user_auth_by_provider
key_path: usage_activity_by_stage.manage.user_auth_by_provider.two-factor name: count_distinct_users_using_two_factor_authentication
description: Number of unique user logins using two factor authentication description: Number of unique user logins using two factor authentication for available providers
product_section: dev product_section: dev
product_stage: manage product_stage: manage
product_group: group::access product_group: group::access
product_category: authentication_and_authorization product_category: authentication_and_authorization
value_type: number value_type: object
status: active status: active
milestone: "14.3"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70061
time_frame: all time_frame: all
data_source: database data_source: database
data_category: optional
performance_indicator_type: []
distribution: distribution:
- ce - ce
- ee
tier: tier:
- free - free
- premium - premium
- ultimate - ultimate
milestone: "<13.9" value_json_schema: "config/metrics/objects_schemas/user_auth_by_provider.json"
{
"type": "object",
"description": "Distinct users by provider",
"properties": {
"two-factor": {"type": "number", "description": " Number of unique user logins using two factor authentication" },
"two-factor-via-u2f-device": {"type": "number", "description": " Number of unique user logins using two factor authentication via U2F" },
"two-factor-via-webauthn-device": {"type": "number", "description": " Number of unique user logins using two factor authentication via two-factor-via-webauthn-device" },
"standard": {"type": "number", "description": " Number of unique user logins using password authentication" },
"google_oauth2": {"type": "number", "description": " Number of unique user logins using Google OAuth authentication" },
"twitter": {"type": "number", "description": " Number of unique user logins using Twitter authentication" },
"github": {"type": "number", "description": " Number of unique user logins using Github authentication" },
"bitbucket": {"type": "number", "description": " Number of unique user logins using Bitbucket authentication" },
"group_saml": {"type": "number", "description": " Number of unique user logins using group SAML authentication" },
"salesforce": {"type": "number", "description": " Number of unique user logins using group Salesforce authentication" }
}
}
...@@ -20,13 +20,13 @@ module EE ...@@ -20,13 +20,13 @@ module EE
end end
def filtered_usage_data(payload = raw_payload, parents = []) def filtered_usage_data(payload = raw_payload, parents = [])
return if payload.nil? return unless payload.is_a?(Hash)
payload.keep_if do |label, node| payload.keep_if do |label, node|
if leaf?(node) if has_metric_definition?(label, parents)
permitted_categories.include?(metric_category(label, parents)) permitted_metric?(label, parents)
else else
filtered_usage_data(node, parents.dup << label) filtered_usage_data(node, parents.dup << label) if node.is_a?(Hash)
end end
end end
end end
...@@ -35,6 +35,15 @@ module EE ...@@ -35,6 +35,15 @@ module EE
@permitted_categories ||= ::ServicePing::PermitDataCategoriesService.new.execute @permitted_categories ||= ::ServicePing::PermitDataCategoriesService.new.execute
end end
def permitted_metric?(key, parent_keys)
permitted_categories.include?(metric_category(key, parent_keys))
end
def has_metric_definition?(key, parent_keys)
key_path = parent_keys.dup.append(key).join('.')
metric_definitions[key_path].present?
end
def metric_category(key, parent_keys) def metric_category(key, parent_keys)
key_path = parent_keys.dup.append(key).join('.') key_path = parent_keys.dup.append(key).join('.')
metric_definitions[key_path] metric_definitions[key_path]
...@@ -45,10 +54,6 @@ module EE ...@@ -45,10 +54,6 @@ module EE
def metric_definitions def metric_definitions
@metric_definitions ||= ::Gitlab::Usage::MetricDefinition.definitions @metric_definitions ||= ::Gitlab::Usage::MetricDefinition.definitions
end end
def leaf?(node)
!node.is_a?(Hash)
end
end end
end end
end end
...@@ -6,21 +6,25 @@ RSpec.shared_context 'stubbed service ping metrics definitions' do ...@@ -6,21 +6,25 @@ RSpec.shared_context 'stubbed service ping metrics definitions' do
let(:metrics_definitions) { standard_metrics + subscription_metrics + operational_metrics + optional_metrics } let(:metrics_definitions) { standard_metrics + subscription_metrics + operational_metrics + optional_metrics }
let(:standard_metrics) do let(:standard_metrics) do
[ [
metric_attributes('uuid', "standard") metric_attributes('uuid', 'standard'),
metric_attributes('recorded_at', 'standard'),
metric_attributes('settings.collected_data_categories', 'standard', 'object')
] ]
end end
let(:operational_metrics) do let(:operational_metrics) do
[ [
metric_attributes('counts.merge_requests', "operational"), metric_attributes('counts.merge_requests', 'operational'),
metric_attributes('counts.todos', "operational") metric_attributes('counts.todos', "operational")
] ]
end end
let(:optional_metrics) do let(:optional_metrics) do
[ [
metric_attributes('counts.boards', "optional"), metric_attributes('counts.boards', 'optional', 'number'),
metric_attributes('gitaly.filesystems', '').except('data_category') metric_attributes('gitaly.filesystems', '').except('data_category'),
metric_attributes('usage_activity_by_stage.monitor.projects_with_enabled_alert_integrations_histogram', 'optional', 'object'),
metric_attributes('topology', 'optional', 'object')
] ]
end end
...@@ -34,10 +38,11 @@ RSpec.shared_context 'stubbed service ping metrics definitions' do ...@@ -34,10 +38,11 @@ RSpec.shared_context 'stubbed service ping metrics definitions' do
) )
end end
def metric_attributes(key_path, category) def metric_attributes(key_path, category, value_type = 'string')
{ {
'key_path' => key_path, 'key_path' => key_path,
'data_category' => category 'data_category' => category,
'value_type' => value_type
} }
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment