Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-16 09:08:48 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-16 09:08:48 +0300
commitb394e58cc2e52e17e7991e3d7b705aa383c362ee (patch)
treec8fd512f3b9018ff2d007161b825ff22463370d4 /doc/development/service_ping
parente5aec0ddbc6e3122f5e2425e92b30c4cd2184c90 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/service_ping')
-rw-r--r--doc/development/service_ping/implement.md885
-rw-r--r--doc/development/service_ping/index.md512
-rw-r--r--doc/development/service_ping/metrics_dictionary.md337
-rw-r--r--doc/development/service_ping/metrics_instrumentation.md481
-rw-r--r--doc/development/service_ping/metrics_lifecycle.md109
-rw-r--r--doc/development/service_ping/performance_indicator_metrics.md19
-rw-r--r--doc/development/service_ping/review_guidelines.md83
-rw-r--r--doc/development/service_ping/troubleshooting.md167
-rw-r--r--doc/development/service_ping/usage_data.md72
9 files changed, 63 insertions, 2602 deletions
diff --git a/doc/development/service_ping/implement.md b/doc/development/service_ping/implement.md
index 0677e8febf3..c1077793fb9 100644
--- a/doc/development/service_ping/implement.md
+++ b/doc/development/service_ping/implement.md
@@ -1,882 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/implement.md'
+remove_date: '2023-08-20'
---
-# Implement Service Ping
+This document was moved to [another location](../internal_analytics/service_ping/implement.md).
-Service Ping consists of two kinds of data:
-
-- **Counters**: Track how often a certain event happened over time, such as how many CI/CD pipelines have run.
- They are monotonic and usually trend up.
-- **Observations**: Facts collected from one or more GitLab instances and can carry arbitrary data.
- There are no general guidelines for how to collect those, due to the individual nature of that data.
-
-To implement a new metric in Service Ping, follow these steps:
-
-1. [Implement the required counter](#types-of-counters)
-1. [Name and place the metric](metrics_dictionary.md#metric-key_path)
-1. [Test counters manually using your Rails console](#test-counters-manually-using-your-rails-console)
-1. [Generate the SQL query](#generate-the-sql-query)
-1. [Optimize queries with Database Lab](#optimize-queries-with-database-lab)
-1. [Add the metric definition to the Metrics Dictionary](#add-the-metric-definition)
-1. [Add the metric to the Versions Application](#add-the-metric-to-the-versions-application)
-1. [Create a merge request](#create-a-merge-request)
-1. [Verify your metric](#verify-your-metric)
-1. [Set up and test Service Ping locally](#set-up-and-test-service-ping-locally)
-
-## Instrumentation classes
-
-NOTE:
-Implementing metrics directly in `usage_data.rb` is deprecated.
-When you add or change a Service Ping Metric, you must migrate metrics to [instrumentation classes](metrics_instrumentation.md).
-For information about the progress on migrating Service Ping metrics, see this [epic](https://gitlab.com/groups/gitlab-org/-/epics/5547).
-
-For example, we have the following instrumentation class:
-`lib/gitlab/usage/metrics/instrumentations/count_boards_metric.rb`.
-
-You should add it to `usage_data.rb` as follows:
-
-```ruby
-boards: add_metric('CountBoardsMetric', time_frame: 'all'),
-```
-
-## Types of counters
-
-There are several types of counters for metrics:
-
-- **[Batch counters](#batch-counters)**: Used for counts, sums, and averages.
-- **[Redis counters](#redis-counters):** Used for in-memory counts.
-- **[Alternative counters](#alternative-counters):** Used for settings and configurations.
-
-NOTE:
-Only use the provided counter methods. Each counter method contains a built-in fail-safe mechanism that isolates each counter to avoid breaking the entire Service Ping process.
-
-### Batch counters
-
-For large tables, PostgreSQL can take a long time to count rows due to MVCC [(Multi-version Concurrency Control)](https://en.wikipedia.org/wiki/Multiversion_concurrency_control). Batch counting is a counting method where a single large query is broken into multiple smaller queries. For example, instead of a single query querying 1,000,000 records, with batch counting, you can execute 100 queries of 10,000 records each. Batch counting is useful for avoiding database timeouts as each batch query is significantly shorter than one single long running query.
-
-For GitLab.com, there are extremely large tables with 15 second query timeouts, so we use batch counting to avoid encountering timeouts. Here are the sizes of some GitLab.com tables:
-
-| Table | Row counts in millions |
-|------------------------------|------------------------|
-| `merge_request_diff_commits` | 2280 |
-| `ci_build_trace_sections` | 1764 |
-| `merge_request_diff_files` | 1082 |
-| `events` | 514 |
-
-Batch counting requires indexes on columns to calculate max, min, and range queries. In some cases,
-you must add a specialized index on the columns involved in a counter.
-
-#### Ordinary batch counters
-
-Create a new [database metrics](metrics_instrumentation.md#database-metrics) instrumentation class with `count` operation for a given `ActiveRecord_Relation`
-
-Method:
-
-```ruby
-add_metric('CountIssuesMetric', time_frame: 'all')
-```
-
-Examples:
-
-Examples using `usage_data.rb` have been [deprecated](usage_data.md). We recommend to use [instrumentation classes](metrics_instrumentation.md).
-
-#### Distinct batch counters
-
-Create a new [database metrics](metrics_instrumentation.md#database-metrics) instrumentation class with `distinct_count` operation for a given `ActiveRecord_Relation`.
-
-Method:
-
-```ruby
-add_metric('CountUsersAssociatingMilestonesToReleasesMetric', time_frame: 'all')
-```
-
-WARNING:
-Counting over non-unique columns can lead to performance issues. For more information, see the [iterating tables in batches](../database/iterating_tables_in_batches.md) guide.
-
-Examples:
-
-Examples using `usage_data.rb` have been [deprecated](usage_data.md). We recommend to use [instrumentation classes](metrics_instrumentation.md).
-
-#### Sum batch operation
-
-Sum the values of a given ActiveRecord_Relation on given column and handles errors.
-Handles the `ActiveRecord::StatementInvalid` error
-
-Method:
-
-```ruby
-add_metric('JiraImportsTotalImportedIssuesCountMetric')
-```
-
-#### Average batch operation
-
-Average the values of a given `ActiveRecord_Relation` on given column and handles errors.
-
-Method:
-
-```ruby
-add_metric('CountIssuesWeightAverageMetric')
-```
-
-Examples:
-
-Examples using `usage_data.rb` have been [deprecated](usage_data.md). We recommend to use [instrumentation classes](metrics_instrumentation.md).
-
-#### Grouping and batch operations
-
-The `count`, `distinct_count` and `sum` batch counters can accept an `ActiveRecord::Relation`
-object, which groups by a specified column. With a grouped relation, the methods do batch counting,
-handle errors, and returns a hash table of key-value pairs.
-
-Examples:
-
-```ruby
-count(Namespace.group(:type))
-# returns => {nil=>179, "Group"=>54}
-
-distinct_count(Project.group(:visibility_level), :creator_id)
-# returns => {0=>1, 10=>1, 20=>11}
-
-sum(Issue.group(:state_id), :weight))
-# returns => {1=>3542, 2=>6820}
-```
-
-#### Add operation
-
-Sum the values given as parameters. Handles the `StandardError`.
-Returns `-1` if any of the arguments are `-1`.
-
-Method:
-
-```ruby
-add(*args)
-```
-
-Examples:
-
-```ruby
-project_imports = distinct_count(::Project.where.not(import_type: nil), :creator_id)
-bulk_imports = distinct_count(::BulkImport, :user_id)
-
- add(project_imports, bulk_imports)
-```
-
-#### Estimated batch counters
-
-> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48233) in GitLab 13.7.
-
-Estimated batch counter functionality handles `ActiveRecord::StatementInvalid` errors
-when used through the provided `estimate_batch_distinct_count` method.
-Errors return a value of `-1`.
-
-WARNING:
-This functionality estimates a distinct count of a specific ActiveRecord_Relation in a given column,
-which uses the [HyperLogLog](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/40671.pdf) algorithm.
-As the HyperLogLog algorithm is probabilistic, the **results always include error**.
-The highest encountered error rate is 4.9%.
-
-When correctly used, the `estimate_batch_distinct_count` method enables efficient counting over
-columns that contain non-unique values, which cannot be assured by other counters.
-
-##### `estimate_batch_distinct_count` method
-
-Method:
-
-```ruby
-estimate_batch_distinct_count(relation, column = nil, batch_size: nil, start: nil, finish: nil)
-```
-
-The [method](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/utils/usage_data.rb#L63)
-includes the following arguments:
-
-- `relation`: The ActiveRecord_Relation to perform the count.
-- `column`: The column to perform the distinct count. The default is the primary key.
-- `batch_size`: From `Gitlab::Database::PostgresHll::BatchDistinctCounter::DEFAULT_BATCH_SIZE`. Default value: 10,000.
-- `start`: The custom start of the batch count, to avoid complex minimum calculations.
-- `finish`: The custom end of the batch count to avoid complex maximum calculations.
-
-The method includes the following prerequisites:
-
-- The supplied `relation` must include the primary key defined as the numeric column.
- For example: `id bigint NOT NULL`.
-- The `estimate_batch_distinct_count` can handle a joined relation. To use its ability to
- count non-unique columns, the joined relation **must not** have a one-to-many relationship,
- such as `has_many :boards`.
-- Both `start` and `finish` arguments should always represent primary key relationship values,
- even if the estimated count refers to another column, for example:
-
- ```ruby
- estimate_batch_distinct_count(::Note, :author_id, start: ::Note.minimum(:id), finish: ::Note.maximum(:id))
- ```
-
-Examples:
-
-1. Simple execution of estimated batch counter, with only relation provided,
- returned value represents estimated number of unique values in `id` column
- (which is the primary key) of `Project` relation:
-
- ```ruby
- estimate_batch_distinct_count(::Project)
- ```
-
-1. Execution of estimated batch counter, where provided relation has applied
- additional filter (`.where(time_period)`), number of unique values estimated
- in custom column (`:author_id`), and parameters: `start` and `finish` together
- apply boundaries that defines range of provided relation to analyze:
-
- ```ruby
- estimate_batch_distinct_count(::Note.with_suggestions.where(time_period), :author_id, start: ::Note.minimum(:id), finish: ::Note.maximum(:id))
- ```
-
-When instrumenting metric with usage of estimated batch counter please add
-`_estimated` suffix to its name, for example:
-
-```ruby
- "counts": {
- "ci_builds_estimated": estimate_batch_distinct_count(Ci::Build),
- ...
-```
-
-### Redis counters
-
-Handles `::Redis::CommandError` and `Gitlab::UsageDataCounters::BaseCounter::UnknownEvent`.
-Returns -1 when a block is sent or hash with all values and -1 when a `counter(Gitlab::UsageDataCounters)` is sent.
-The different behavior is due to 2 different implementations of the Redis counter.
-
-Method:
-
-```ruby
-redis_usage_data(counter, &block)
-```
-
-Arguments:
-
-- `counter`: a counter from `Gitlab::UsageDataCounters`, that has `fallback_totals` method implemented
-- or a `block`: which is evaluated
-
-#### Ordinary Redis counters
-
-Example of implementation: [`Gitlab::UsageDataCounters::WikiPageCounter`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters/wiki_page_counter.rb), using Redis methods [`INCR`](https://redis.io/commands/incr/) and [`GET`](https://redis.io/commands/get/).
-
-Events are handled by counter classes in the `Gitlab::UsageDataCounters` namespace, inheriting from `BaseCounter`, that are either:
-
-1. Listed in [`Gitlab::UsageDataCounters::COUNTERS`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters.rb#L5) to be then included in `Gitlab::UsageData`.
-
-1. Specified in the metric definition using the `RedisMetric` instrumentation class by their `prefix` option to be picked up using the [metric instrumentation](metrics_instrumentation.md) framework. Refer to the [Redis metrics](metrics_instrumentation.md#redis-metrics) documentation for an example implementation.
-
-Inheriting classes are expected to override `KNOWN_EVENTS` and `PREFIX` constants to build event names and associated metrics. For example, for prefix `issues` and events array `%w[create, update, delete]`, three metrics will be added to the Service Ping payload: `counts.issues_create`, `counts.issues_update` and `counts.issues_delete`.
-
-##### `UsageData` API
-
-You can use the `UsageData` API to track events.
-To track events, the `usage_data_api` feature flag must
-be enabled (set to `default_enabled: true`).
-Enabled by default in GitLab 13.7 and later.
-
-##### UsageData API tracking
-
-1. Track events using the [`UsageData` API](#usagedata-api).
-
- Increment event count using an ordinary Redis counter, for a given event name.
-
- API requests are protected by checking for a valid CSRF token.
-
- ```plaintext
- POST /usage_data/increment_counter
- ```
-
- | Attribute | Type | Required | Description |
- | :-------- | :--- | :------- | :---------- |
- | `event` | string | yes | The event name to track. |
-
- Response:
-
- - `200` if the event was tracked.
- - `400 Bad request` if the event parameter is missing.
- - `401 Unauthorized` if the user is not authenticated.
- - `403 Forbidden` if an invalid CSRF token is provided.
-
-1. Track events using the JavaScript/Vue API helper which calls the [`UsageData` API](#usagedata-api).
-
- To track events, `usage_data_api` and `usage_data_#{event_name}` must be enabled.
-
- ```javascript
- import api from '~/api';
-
- api.trackRedisCounterEvent('my_already_defined_event_name'),
- ```
-
-#### Redis HLL counters
-
-WARNING:
-HyperLogLog (HLL) is a probabilistic algorithm and its **results always includes some small error**. According to [Redis documentation](https://redis.io/commands/pfcount/), data from
-used HLL implementation is "approximated with a standard error of 0.81%".
-
-NOTE:
- A user's consent for `usage_stats` (`User.single_user&.requires_usage_stats_consent?`) is not checked during the data tracking stage due to performance reasons. Keys corresponding to those counters are present in Redis even if `usage_stats_consent` is still required. However, no metric is collected from Redis and reported back to GitLab as long as `usage_stats_consent` is required.
-
-With `Gitlab::UsageDataCounters::HLLRedisCounter` we have available data structures used to count unique values.
-
-Implemented using Redis methods [PFADD](https://redis.io/commands/pfadd/) and [PFCOUNT](https://redis.io/commands/pfcount/).
-
-##### Add new events
-
-1. Define events in [`known_events`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters/known_events/).
-
- Example event:
-
- ```yaml
- - name: users_creating_epics
- aggregation: weekly
- ```
-
- Keys:
-
- - `name`: unique event name.
-
- Name format for Redis HLL events `{hll_counters}_<name>`
-
- Example names: `users_creating_epics`, `users_triggering_security_scans`.
-
- - `aggregation`: may be set to a `:daily` or `:weekly` key. Defines how counting data is stored in Redis.
- Aggregation on a `daily` basis does not pull more fine grained data.
-
-1. Use one of the following methods to track the event:
-
- - In the controller using the `ProductAnalyticsTracking` module and the following format:
-
- ```ruby
- track_event(*controller_actions, name:, action:, label:, conditions: nil, destinations: [:redis_hll], &block)
- ```
-
- Arguments:
-
- - `controller_actions`: the controller actions to track.
- - `name`: the event name.
- - `action`: required if destination is `:snowplow. Action name for the triggered event. See [event schema](../snowplow/index.md#event-schema) for more details.
- - `label`: required if destination is `:snowplow. Label for the triggered event. See [event schema](../snowplow/index.md#event-schema) for more details.
- - `conditions`: optional custom conditions. Uses the same format as Rails callbacks.
- - `destinations`: optional list of destinations. Currently supports `:redis_hll` and `:snowplow`. Default: `:redis_hll`.
- - `&block`: optional block that computes and returns the `custom_id` that we want to track. This overrides the `visitor_id`.
-
- Example:
-
- ```ruby
- # controller
- class ProjectsController < Projects::ApplicationController
- include ProductAnalyticsTracking
-
- skip_before_action :authenticate_user!, only: :show
- track_event :index, :show,
- name: 'users_visiting_projects',
- action: 'user_perform_visit',
- label: 'redis_hll_counters.users_visiting_project_monthly',
- destinations: %i[redis_hll snowplow]
-
- def index
- render html: 'index'
- end
-
- def new
- render html: 'new'
- end
-
- def show
- render html: 'show'
- end
- end
- ```
-
- - In the API using the `increment_unique_values(event_name, values)` helper method.
-
- Arguments:
-
- - `event_name`: the event name.
- - `values`: the values counted. Can be one value or an array of values.
-
- Example:
-
- ```ruby
- get ':id/registry/repositories' do
- repositories = ContainerRepositoriesFinder.new(
- user: current_user, subject: user_group
- ).execute
-
- increment_unique_values('users_listing_repositories', current_user.id)
-
- present paginate(repositories), with: Entities::ContainerRegistry::Repository, tags: params[:tags], tags_count: params[:tags_count]
- end
- ```
-
- - Using `track_usage_event(event_name, values)` in services and GraphQL.
-
- Increment unique values count using Redis HLL, for a given event name.
-
- Examples:
-
- - [Track usage event for an incident in a service](https://gitlab.com/gitlab-org/gitlab/-/blob/v13.8.3-ee/app/services/issues/update_service.rb#L66)
- - [Track usage event for an incident in GraphQL](https://gitlab.com/gitlab-org/gitlab/-/blob/v13.8.3-ee/app/graphql/mutations/alert_management/update_alert_status.rb#L16)
-
- ```ruby
- track_usage_event(:incident_management_incident_created, current_user.id)
- ```
-
- - Using the [`UsageData` API](#usagedata-api).
-
- Increment unique users count using Redis HLL, for a given event name.
-
- API requests are protected by checking for a valid CSRF token.
-
- ```plaintext
- POST /usage_data/increment_unique_users
- ```
-
- | Attribute | Type | Required | Description |
- | :-------- | :--- | :------- | :---------- |
- | `event` | string | yes | The event name to track |
-
- Response:
-
- - `200` if the event was tracked, or if tracking failed for any reason.
- - `400 Bad request` if an event parameter is missing.
- - `401 Unauthorized` if the user is not authenticated.
- - `403 Forbidden` if an invalid CSRF token is provided.
-
- - Using the JavaScript/Vue API helper, which calls the [`UsageData` API](#usagedata-api).
-
- Example for an existing event already defined in [known events](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters/known_events/):
-
- ```javascript
- import api from '~/api';
-
- api.trackRedisHllUserEvent('my_already_defined_event_name'),
- ```
-
-1. Get event data using `Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names:, start_date:, end_date:, context: '')`.
-
- Arguments:
-
- - `event_names`: the list of event names.
- - `start_date`: start date of the period for which we want to get event data.
- - `end_date`: end date of the period for which we want to get event data.
- - `context`: context of the event. Allowed values are `default`, `free`, `bronze`, `silver`, `gold`, `starter`, `premium`, `ultimate`.
-
-1. Testing tracking and getting unique events
-
-Trigger events in rails console by using `track_event` method
-
- ```ruby
- Gitlab::UsageDataCounters::HLLRedisCounter.track_event('users_viewing_compliance_audit_events', values: 1)
- Gitlab::UsageDataCounters::HLLRedisCounter.track_event('users_viewing_compliance_audit_events', values: [2, 3])
- ```
-
-Next, get the unique events for the current week.
-
- ```ruby
- # Get unique events for metric for current_week
- Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names: 'users_viewing_compliance_audit_events',
- start_date: Date.current.beginning_of_week, end_date: Date.current.next_week)
- ```
-
-##### Recommendations
-
-We have the following recommendations for [adding new events](#add-new-events):
-
-- Event aggregation: weekly.
-- When adding new metrics, use a [feature flag](../../operations/feature_flags.md) to control the impact.
-It's recommended to disable the new feature flag by default (set `default_enabled: false`).
-- Events can be triggered using the `UsageData` API, which helps when there are > 10 events per change
-
-##### Enable or disable Redis HLL tracking
-
-We can disable tracking completely by using the global flag:
-
-```shell
-/chatops run feature set redis_hll_tracking true
-/chatops run feature set redis_hll_tracking false
-```
-
-##### Known events are added automatically in Service Data payload
-
-Service Ping adds all events [`known_events/*.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters/known_events) to Service Data generation under the `redis_hll_counters` key. This column is stored in [version-app as a JSON](https://gitlab.com/gitlab-services/version-gitlab-com/-/blob/master/db/schema.rb#L209).
-For each event we add metrics for the weekly and monthly time frames, and totals for each where applicable:
-
-- `#{event_name}_weekly`: Data for 7 days for daily [aggregation](#add-new-events) events and data for the last complete week for weekly [aggregation](#add-new-events) events.
-- `#{event_name}_monthly`: Data for 28 days for daily [aggregation](#add-new-events) events and data for the last 4 complete weeks for weekly [aggregation](#add-new-events) events.
-
-Example of `redis_hll_counters` data:
-
-```ruby
-{:redis_hll_counters=>
- {"compliance"=>
- {"users_viewing_compliance_dashboard_weekly"=>0,
- "users_viewing_compliance_dashboard_monthly"=>0,
- "users_viewing_compliance_audit_events_weekly"=>0,
- "users_viewing_audit_events_monthly"=>0,
- "compliance_total_unique_counts_weekly"=>0,
- "compliance_total_unique_counts_monthly"=>0},
- "analytics"=>
- {"users_viewing_analytics_group_devops_adoption_weekly"=>0,
- "users_viewing_analytics_group_devops_adoption_monthly"=>0,
- "analytics_total_unique_counts_weekly"=>0,
- "analytics_total_unique_counts_monthly"=>0},
- "ide_edit"=>
- {"users_editing_by_web_ide_weekly"=>0,
- "users_editing_by_web_ide_monthly"=>0,
- "users_editing_by_sfe_weekly"=>0,
- "users_editing_by_sfe_monthly"=>0,
- "ide_edit_total_unique_counts_weekly"=>0,
- "ide_edit_total_unique_counts_monthly"=>0}
- }
-}
-```
-
-Example:
-
-```ruby
-# Redis Counters
-redis_usage_data(Gitlab::UsageDataCounters::WikiPageCounter)
-
-# Define events in common.yml https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters/known_events/common.yml
-
-# Tracking events
-Gitlab::UsageDataCounters::HLLRedisCounter.track_event('users_expanding_vulnerabilities', values: visitor_id)
-
-# Get unique events for metric
-redis_usage_data { Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names: 'users_expanding_vulnerabilities', start_date: 28.days.ago, end_date: Date.current) }
-```
-
-### Alternative counters
-
-Handles `StandardError` and fallbacks into -1 this way not all measures fail if we encounter one exception.
-Mainly used for settings and configurations.
-
-Method:
-
-```ruby
-alt_usage_data(value = nil, fallback: -1, &block)
-```
-
-Arguments:
-
-- `value`: a static value in which case the value is returned.
-- or a `block`: which is evaluated
-- `fallback: -1`: the common value used for any metrics that are failing.
-
-Example:
-
-```ruby
-alt_usage_data { Gitlab::VERSION }
-alt_usage_data { Gitlab::CurrentSettings.uuid }
-alt_usage_data(999)
-```
-
-### Add counters to build new metrics
-
-When adding the results of two counters, use the `add` Service Data method that
-handles fallback values and exceptions. It also generates a valid [SQL export](index.md#export-service-ping-data).
-
-Example:
-
-```ruby
-add(User.active, User.bot)
-```
-
-### Prometheus queries
-
-In those cases where operational metrics should be part of Service Ping, a database or Redis query is unlikely
-to provide useful data. Instead, Prometheus might be more appropriate, because most GitLab architectural
-components publish metrics to it that can be queried back, aggregated, and included as Service Data.
-
-NOTE:
-Prometheus as a data source for Service Ping is only available for single-node Omnibus installations
-that are running the [bundled Prometheus](../../administration/monitoring/prometheus/index.md) instance.
-
-To query Prometheus for metrics, a helper method is available to `yield` a fully configured
-`PrometheusClient`, given it is available as per the note above:
-
-```ruby
-with_prometheus_client do |client|
- response = client.query('<your query>')
- ...
-end
-```
-
-Refer to [the `PrometheusClient` definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/prometheus_client.rb)
-for how to use its API to query for data.
-
-### Fallback values for Service Ping
-
-We return fallback values in these cases:
-
-| Case | Value |
-|-----------------------------|-------|
-| Deprecated Metric ([Removed with version 14.3](https://gitlab.com/gitlab-org/gitlab/-/issues/335894)) | -1000 |
-| Timeouts, general failures | -1 |
-| Standard errors in counters | -2 |
-| Histogram metrics failure | { '-1' => -1 } |
-
-## Test counters manually using your Rails console
-
-```ruby
-# count
-Gitlab::UsageData.count(User.active)
-Gitlab::UsageData.count(::Clusters::Cluster.aws_installed.enabled, :cluster_id)
-
-# count distinct
-Gitlab::UsageData.distinct_count(::Project, :creator_id)
-Gitlab::UsageData.distinct_count(::Note.with_suggestions.where(time_period), :author_id, start: ::User.minimum(:id), finish: ::User.maximum(:id))
-```
-
-## Generate the SQL query
-
-Your Rails console returns the generated SQL queries. For example:
-
-```ruby
-pry(main)> Gitlab::UsageData.count(User.active)
- (2.6ms) SELECT "features"."key" FROM "features"
- (15.3ms) SELECT MIN("users"."id") FROM "users" WHERE ("users"."state" IN ('active')) AND ("users"."user_type" IS NULL OR "users"."user_type" IN (6, 4))
- (2.4ms) SELECT MAX("users"."id") FROM "users" WHERE ("users"."state" IN ('active')) AND ("users"."user_type" IS NULL OR "users"."user_type" IN (6, 4))
- (1.9ms) SELECT COUNT("users"."id") FROM "users" WHERE ("users"."state" IN ('active')) AND ("users"."user_type" IS NULL OR "users"."user_type" IN (6, 4)) AND "users"."id" BETWEEN 1 AND 100000
-```
-
-## Optimize queries with Database Lab
-
-[Database Lab](../database/database_lab.md) is a service that uses a production clone to test queries.
-
-- GitLab.com's production database has a 15 second timeout.
-- Any single query must stay below the [1 second execution time](../database/query_performance.md#timing-guidelines-for-queries) with cold caches.
-- Add a specialized index on columns involved to reduce the execution time.
-
-To understand the query's execution, we add the following information
-to a merge request description:
-
-- For counters that have a `time_period` test, we add information for both:
- - `time_period = {}` for all time periods.
- - `time_period = { created_at: 28.days.ago..Time.current }` for the last 28 days.
-- Execution plan and query time before and after optimization.
-- Query generated for the index and time.
-- Migration output for up and down execution.
-
-For more details, see the [database review guide](../database_review.md#preparation-when-adding-or-modifying-queries).
-
-### Optimization recommendations and examples
-
-- Use specialized indexes. For examples, see these merge requests:
- - [Example 1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26871)
- - [Example 2](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26445)
-- Use defined `start` and `finish`. These values can be memoized and reused, as in this
- [example merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37155).
-- Avoid joins and unnecessary complexity in your queries. See this
- [example merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36316) as an example.
-- Set a custom `batch_size` for `distinct_count`, as in this [example merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38000).
-
-## Add the metric definition
-
-See the [Metrics Dictionary guide](metrics_dictionary.md) for more information.
-
-## Add the metric to the Versions Application
-
-Check if the new metric must be added to the Versions Application. See the `usage_data` [schema](https://gitlab.com/gitlab-services/version-gitlab-com/-/blob/master/db/schema.rb#L147) and Service Data [parameters accepted](https://gitlab.com/gitlab-services/version-gitlab-com/-/blob/master/app/services/usage_ping.rb). Any metrics added under the `counts` key are saved in the `stats` column.
-
-## Create a merge request
-
-Create a merge request for the new Service Ping metric, and do the following:
-
-- Add the `feature` label to the merge request. A metric is a user-facing change and is part of expanding the Service Ping feature.
-- Add a changelog entry that complies with the [changelog entries guide](../changelog.md).
-- Ask for an Analytics Instrumentation review.
- On GitLab.com, we have DangerBot set up to monitor Analytics Instrumentation related files and recommend a [Analytics Instrumentation review](review_guidelines.md).
-
-## Verify your metric
-
-On GitLab.com, the Analytics Instrumentation team regularly [monitors Service Ping](https://gitlab.com/groups/gitlab-org/-/epics/6000).
-They may alert you that your metrics need further optimization to run quicker and with greater success.
-
-The Service Ping JSON payload for GitLab.com is shared in the
-[#g_analyze_analytics_instrumentation](https://gitlab.slack.com/archives/CL3A7GFPF) Slack channel every week.
-
-You may also use the [Service Ping QA dashboard](https://app.periscopedata.com/app/gitlab/632033/Usage-Ping-QA) to check how well your metric performs.
-The dashboard allows filtering by GitLab version, by "Self-managed" and "SaaS", and shows you how many failures have occurred for each metric. Whenever you notice a high failure rate, you can re-optimize your metric.
-
-Use [Metrics Dictionary](https://metrics.gitlab.com/) [copy query to clipboard feature](https://www.youtube.com/watch?v=n4o65ivta48&list=PL05JrBw4t0Krg3mbR6chU7pXtMt_es6Pb) to get a query ready to run in Sisense for a specific metric.
-
-## Set up and test Service Ping locally
-
-To set up Service Ping locally, you must:
-
-1. [Set up local repositories](#set-up-local-repositories).
-1. [Test local setup](#test-local-setup).
-1. Optional. [Test Prometheus-based Service Ping](#test-prometheus-based-service-ping).
-
-### Set up local repositories
-
-1. Clone and start [GitLab](https://gitlab.com/gitlab-org/gitlab-development-kit).
-1. Clone and start [Versions Application](https://gitlab.com/gitlab-services/version-gitlab-com).
- Make sure you run `docker-compose up` to start a PostgreSQL and Redis instance.
-1. Point GitLab to the Versions Application endpoint instead of the default endpoint:
- 1. Open [service_ping/submit_service.rb](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/services/service_ping/submit_service.rb#L5) locally and modify `STAGING_BASE_URL`.
- 1. Set it to the local Versions Application URL: `http://localhost:3000`.
-
-### Test local setup
-
-1. Using the `gitlab` Rails console, manually trigger Service Ping:
-
- ```ruby
- GitlabServicePingWorker.new.perform('triggered_from_cron' => false)
- ```
-
-1. Use the `versions` Rails console to check the Service Ping was successfully received,
- parsed, and stored in the Versions database:
-
- ```ruby
- UsageData.last
- ```
-
-## Test Prometheus-based Service Ping
-
-If the data submitted includes metrics [queried from Prometheus](#prometheus-queries)
-you want to inspect and verify, you must:
-
-- Ensure that a Prometheus server is running locally.
-- Ensure the respective GitLab components are exporting metrics to the Prometheus server.
-
-If you do not need to test data coming from Prometheus, no further action
-is necessary. Service Ping should degrade gracefully in the absence of a running Prometheus server.
-
-Three kinds of components may export data to Prometheus, and are included in Service Ping:
-
-- [`node_exporter`](https://github.com/prometheus/node_exporter): Exports node metrics
- from the host machine.
-- [`gitlab-exporter`](https://gitlab.com/gitlab-org/gitlab-exporter): Exports process metrics
- from various GitLab components.
-- Other various GitLab services, such as Sidekiq and the Rails server, which export their own metrics.
-
-### Test with an Omnibus container
-
-This is the recommended approach to test Prometheus-based Service Ping.
-
-To verify your change, build a new Omnibus image from your code branch using CI/CD, download the image,
-and run a local container instance:
-
-1. From your merge request, select the `qa` stage, then trigger the `e2e:package-and-test` job. This job triggers an Omnibus
- build in a [downstream pipeline of the `omnibus-gitlab-mirror` project](https://gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/-/pipelines).
-1. In the downstream pipeline, wait for the `gitlab-docker` job to finish.
-1. Open the job logs and locate the full container name including the version. It takes the following form: `registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:<VERSION>`.
-1. On your local machine, make sure you are signed in to the GitLab Docker registry. You can find the instructions for this in
- [Authenticate to the GitLab Container Registry](../../user/packages/container_registry/authenticate_with_container_registry.md).
-1. Once signed in, download the new image by using `docker pull registry.gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/gitlab-ee:<VERSION>`
-1. For more information about working with and running Omnibus GitLab containers in Docker, refer to [GitLab Docker images](../../install/docker.md) documentation.
-
-### Test with GitLab development toolkits
-
-This is the less recommended approach, because it comes with a number of difficulties when emulating a real GitLab deployment.
-
-The [GDK](https://gitlab.com/gitlab-org/gitlab-development-kit) is not set up to run a Prometheus server or `node_exporter` alongside other GitLab components. If you would
-like to do so, [Monitoring the GDK with Prometheus](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/prometheus/index.md#monitoring-the-gdk-with-prometheus) is a good start.
-
-The [GCK](https://gitlab.com/gitlab-org/gitlab-compose-kit) has limited support for testing Prometheus based Service Ping.
-By default, it comes with a fully configured Prometheus service that is set up to scrape a number of components.
-However, it has the following limitations:
-
-- It does not run a `gitlab-exporter` instance, so several `process_*` metrics from services such as Gitaly may be missing.
-- While it runs a `node_exporter`, `docker-compose` services emulate hosts, meaning that it normally reports itself as not associated
- with any of the other running services. That is not how node metrics are reported in a production setup, where `node_exporter`
- always runs as a process alongside other GitLab components on any given node. For Service Ping, none of the node data would therefore
- appear to be associated to any of the services running, because they all appear to be running on different hosts. To alleviate this problem, the `node_exporter` in GCK was arbitrarily "assigned" to the `web` service, meaning only for this service `node_*` metrics appears in Service Ping.
-
-## Aggregated metrics
-
-> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45979) in GitLab 13.6.
-
-WARNING:
-This feature is intended solely for internal GitLab use.
-
-The aggregated metrics feature provides insight into the data attributes in a collection of Service Ping metrics.
-This aggregation allows you to count data attributes in events without counting each occurrence of the same data attribute in multiple events.
-For example, you can aggregate the number of users who perform several actions, such as creating a new issue and opening a new merge request.
-You can then count each user that performed any combination of these actions.
-
-### Defining aggregated metric via metric YAML definition
-
-To add data for aggregated metrics to the Service Ping payload,
-create metric YAML definition file following [Aggregated metric instrumentation guide](metrics_instrumentation.md#aggregated-metrics).
-
-### Redis sourced aggregated metrics
-
-> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45979) in GitLab 13.6.
-
-To declare the aggregate of events collected with [Redis HLL Counters](#redis-hll-counters),
-you must fulfill the following requirements:
-
-1. All events listed at `events` attribute must come from
- [`known_events/*.yml`](#known-events-are-added-automatically-in-service-data-payload) files.
-1. All events listed at `events` attribute must have the same `aggregation` attribute.
-1. `time_frame` does not include `all` value, which is unavailable for Redis sourced aggregated metrics.
-
-While it is possible to aggregate EE-only events together with events that occur in all GitLab editions, it's important to remember that doing so may produce high variance between data collected from EE and CE GitLab instances.
-
-### Database sourced aggregated metrics
-
-> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52784) in GitLab 13.9.
-
-To declare an aggregate of metrics based on events collected from database, follow
-these steps:
-
-1. [Persist the metrics for aggregation](#persist-metrics-for-aggregation).
-1. [Add new aggregated metric definition](#add-new-aggregated-metric-definition).
-
-#### Persist metrics for aggregation
-
-Only metrics calculated with [Estimated Batch Counters](#estimated-batch-counters)
-can be persisted for database sourced aggregated metrics. To persist a metric,
-inject a Ruby block into the
-[`estimate_batch_distinct_count`](#estimate_batch_distinct_count-method) method.
-This block should invoke the
-`Gitlab::Usage::Metrics::Aggregates::Sources::PostgresHll.save_aggregated_metrics`
-[method](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage/metrics/aggregates/sources/postgres_hll.rb#L21),
-which stores `estimate_batch_distinct_count` results for future use in aggregated metrics.
-
-The `Gitlab::Usage::Metrics::Aggregates::Sources::PostgresHll.save_aggregated_metrics`
-method accepts the following arguments:
-
-- `metric_name`: The name of metric to use for aggregations. Should be the same
- as the key under which the metric is added into Service Ping.
-- `recorded_at_timestamp`: The timestamp representing the moment when a given
- Service Ping payload was collected. You should use the convenience method `recorded_at`
- to fill `recorded_at_timestamp` argument, like this: `recorded_at_timestamp: recorded_at`
-- `time_period`: The time period used to build the `relation` argument passed into
- `estimate_batch_distinct_count`. To collect the metric with all available historical
- data, set a `nil` value as time period: `time_period: nil`.
-- `data`: HyperLogLog buckets structure representing unique entries in `relation`.
- The `estimate_batch_distinct_count` method always passes the correct argument
- into the block, so `data` argument must always have a value equal to block argument,
- like this: `data: result`
-
-Example metrics persistence:
-
-```ruby
-class UsageData
- def count_secure_pipelines(time_period)
- ...
- relation = ::Security::Scan.by_scan_types(scan_type).where(time_period)
-
- pipelines_with_secure_jobs['dependency_scanning_pipeline'] = estimate_batch_distinct_count(relation, :pipeline_id, batch_size: 1000, start: start_id, finish: finish_id) do |result|
- ::Gitlab::Usage::Metrics::Aggregates::Sources::PostgresHll
- .save_aggregated_metrics(metric_name: 'dependency_scanning_pipeline', recorded_at_timestamp: recorded_at, time_period: time_period, data: result)
- end
- end
-end
-```
-
-#### Add new aggregated metric definition
-
-After all metrics are persisted, you can add an aggregated metric definition following [Aggregated metric instrumentation guide](metrics_instrumentation.md#aggregated-metrics).
-To declare the aggregate of metrics collected with [Estimated Batch Counters](#estimated-batch-counters),
-you must fulfill the following requirements:
-
-- Metrics names listed in the `events:` attribute, have to use the same names you passed in the `metric_name` argument while persisting metrics in previous step.
-- Every metric listed in the `events:` attribute, has to be persisted for **every** selected `time_frame:` value.
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html
diff --git a/doc/development/service_ping/index.md b/doc/development/service_ping/index.md
index 01772b194a4..d0806ed375b 100644
--- a/doc/development/service_ping/index.md
+++ b/doc/development/service_ping/index.md
@@ -1,509 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/index.md'
+remove_date: '2023-08-20'
---
-# Service Ping development guidelines
+This document was moved to [another location](../internal_analytics/service_ping/index.md).
-> - Introduced in GitLab Ultimate 11.2, more statistics.
-> - In GitLab 14.1, [renamed from Usage Ping to Service Ping](https://gitlab.com/groups/gitlab-org/-/epics/5990). In 14.0 and earlier, use the Usage Ping documentation for the Rails commands appropriate to your version.
-
-Service Ping is a GitLab process that collects and sends a weekly payload to GitLab.
-The payload provides important high-level data that helps our product, support,
-and sales teams understand how GitLab is used. The data helps to:
-
-- Compare counts month over month (or week over week) to get a rough sense for how an instance uses
- different product features.
-- Collect other facts that help us classify and understand GitLab installations.
-- Calculate our stage monthly active users (SMAU), which helps to measure the success of our stages
- and features.
-
-Service Ping information is not anonymous. It's linked to the instance's hostname, but does
-not contain project names, usernames, or any other specific data.
-
-Service Ping is enabled by default. However, you can [disable](../../user/admin_area/settings/usage_statistics.md#enable-or-disable-usage-statistics) it on any self-managed instance. When Service Ping is enabled, GitLab gathers data from the other instances and can show your instance's usage statistics to your users.
-
-## Service Ping terminology
-
-We use the following terminology to describe the Service Ping components:
-
-- **Service Ping**: the process that collects and generates a JSON payload.
-- **Service Data**: the contents of the Service Ping JSON payload. This includes metrics.
-- **Metrics**: primarily made up of row counts for different tables in an instance's database. Each
- metric has a corresponding [metric definition](metrics_dictionary.md#metrics-definition-and-validation)
- in a YAML file.
-- **MAU**: monthly active users.
-- **WAU**: weekly active users.
-
-### Limitations
-
-- Service Ping does not track frontend events things like page views, link clicks, or user sessions.
-- Service Ping focuses only on aggregated backend events.
-
-Because of these limitations we recommend you:
-
-- Instrument your products with Snowplow for more detailed analytics on GitLab.com.
-- Use Service Ping to track aggregated backend events on self-managed instances.
-
-## Service Ping request flow
-
-The following example shows a basic request/response flow between a GitLab instance, the Versions Application, the License Application, Salesforce, the GitLab S3 Bucket, the GitLab Snowflake Data Warehouse, and Sisense:
-
-```mermaid
-sequenceDiagram
- participant GitLab Instance
- participant Versions Application
- participant Licenses Application
- participant Salesforce
- participant S3 Bucket
- participant Snowflake DW
- participant Sisense Dashboards
- GitLab Instance->>Versions Application: Send Service Ping
- loop Process usage data
- Versions Application->>Versions Application: Parse usage data
- Versions Application->>Versions Application: Write to database
- Versions Application->>Versions Application: Update license ping time
- end
- loop Process data for Salesforce
- Versions Application-xLicenses Application: Request Zuora subscription id
- Licenses Application-xVersions Application: Zuora subscription id
- Versions Application-xSalesforce: Request Zuora account id by Zuora subscription id
- Salesforce-xVersions Application: Zuora account id
- Versions Application-xSalesforce: Usage data for the Zuora account
- end
- Versions Application->>S3 Bucket: Export Versions database
- S3 Bucket->>Snowflake DW: Import data
- Snowflake DW->>Snowflake DW: Transform data using dbt
- Snowflake DW->>Sisense Dashboards: Data available for querying
- Versions Application->>GitLab Instance: DevOps Score (Conversational Development Index)
-```
-
-## How Service Ping works
-
-1. The Service Ping [cron job](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/workers/gitlab_service_ping_worker.rb#L24) is set in Sidekiq to run weekly.
-1. When the cron job runs, it calls [`Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/services/service_ping/submit_service.rb).
-1. `Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)` [cascades down](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data.rb) to ~400+ other counter method calls.
-1. The response of all methods calls are [merged together](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data.rb#L68) into a single JSON payload.
-1. The JSON payload is then [posted to the Versions application](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/services/service_ping/submit_service.rb#L20)
- If a firewall exception is needed, the required URL depends on several things. If
- the hostname is `version.gitlab.com`, the protocol is `TCP`, and the port number is `443`,
- the required URL is <https://version.gitlab.com/>.
-1. In case of an error, it will be reported to the Version application along with following pieces of information:
-
- - `uuid` - GitLab instance unique identifier
- - `hostname` - GitLab instance hostname
- - `version` - GitLab instance current versions
- - `elapsed` - Amount of time which passed since Service Ping report process started and moment of error occurrence
- - `message` - Error message
-
- <pre>
- <code>
- {
- "uuid"=>"02333324-1cd7-4c3b-a45b-a4993f05fb1d",
- "hostname"=>"127.0.0.1",
- "version"=>"14.7.0-pre",
- "elapsed"=>0.006946,
- "message"=>'PG::UndefinedColumn: ERROR: column \"non_existent_attribute\" does not exist\nLINE 1: SELECT COUNT(non_existent_attribute) FROM \"issues\" /*applica...'
- }
- </code>
- </pre>
-
-1. Finally, the timing metadata information that is used for diagnostic purposes is submitted to the Versions application. It consists of a list of metric identifiers and the time it took to calculate the metrics:
-
- > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37911) in GitLab 15.0 [with a flag](../../user/feature_flags.md), enabled by default.
- > - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/295289) in GitLab 15.2. [Feature flag `measure_service_ping_metric_collection`](https://gitlab.com/gitlab-org/gitlab/-/issues/358128) removed.
-
-```ruby
- {
- "metadata"=>
- {
- "uuid"=>"0000000-0000-0000-0000-000000000000",
- "metrics"=>
- [{"name"=>"version", "time_elapsed"=>1.1811964213848114e-05},
- {"name"=>"installation_type", "time_elapsed"=>0.00017242692410945892},
- {"name"=>"license_billable_users", "time_elapsed"=>0.009520471096038818},
- ....
- {"name"=>"counts.clusters_platforms_eks",
- "time_elapsed"=>0.05638605775311589},
- {"name"=>"counts.clusters_platforms_gke",
- "time_elapsed"=>0.40995341585949063},
- {"name"=>"counts.clusters_platforms_user",
- "time_elapsed"=>0.06410990096628666},
- {"name"=>"counts.clusters_management_project",
- "time_elapsed"=>0.24020783510059118}
- ]
- }
- }
-```
-
-### On a Geo secondary site
-
-We also collect metrics specific to [Geo](../../administration/geo/index.md) secondary sites to send with Service Ping.
-
-1. The [Geo secondary service ping cron job](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/workers/geo/secondary_usage_data_cron_worker.rb) is set in Sidekiq to run weekly.
-1. When the cron job runs, it calls [`SecondaryUsageData.update_metrics!`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/models/geo/secondary_usage_data.rb#L33). This collects the relevant metrics from Prometheus and stores the data in the Geo secondary tracking database for transmission to the primary site during a [Geo node status update](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/models/geo_node_status.rb#L105).
-1. Geo node status data is sent with the JSON payload in the process described above. The following is an example of the payload where each object in the array represents a Geo node:
-
- ```json
- [
- {
- "repository_verification_enabled"=>true,
- "repositories_replication_enabled"=>true,
- "repositories_synced_count"=>24,
- "repositories_failed_count"=>0,
- "git_fetch_event_count_weekly"=>nil,
- "git_push_event_count_weekly"=>nil,
- ... other geo node status fields
- }
- ]
- ```
-
-## Implementing Service Ping
-
-See the [implement Service Ping](implement.md) guide.
-
-## Example Service Ping payload
-
-The following is example content of the Service Ping payload.
-
-```json
-{
- "uuid": "0000000-0000-0000-0000-000000000000",
- "hostname": "example.com",
- "version": "12.10.0-pre",
- "installation_type": "omnibus-gitlab",
- "active_user_count": 999,
- "recorded_at": "2020-04-17T07:43:54.162+00:00",
- "edition": "EEU",
- "license_md5": "00000000000000000000000000000000",
- "license_sha256": "0000000000000000000000000000000000000000000000000000000000000000",
- "license_id": null,
- "historical_max_users": 999,
- "licensee": {
- "Name": "ABC, Inc.",
- "Email": "email@example.com",
- "Company": "ABC, Inc."
- },
- "license_user_count": 999,
- "license_starts_at": "2020-01-01",
- "license_expires_at": "2021-01-01",
- "license_plan": "ultimate",
- "license_add_ons": {
- },
- "license_trial": false,
- "counts": {
- "assignee_lists": 999,
- "boards": 999,
- "ci_builds": 999,
- ...
- },
- "container_registry_enabled": true,
- "dependency_proxy_enabled": false,
- "gitlab_shared_runners_enabled": true,
- "gravatar_enabled": true,
- "influxdb_metrics_enabled": true,
- "ldap_enabled": false,
- "mattermost_enabled": false,
- "omniauth_enabled": true,
- "prometheus_enabled": false,
- "prometheus_metrics_enabled": false,
- "reply_by_email_enabled": "incoming+%{key}@incoming.gitlab.com",
- "signup_enabled": true,
- "projects_with_expiration_policy_disabled": 999,
- "projects_with_expiration_policy_enabled": 999,
- ...
- "elasticsearch_enabled": true,
- "license_trial_ends_on": null,
- "geo_enabled": false,
- "git": {
- "version": {
- "major": 2,
- "minor": 26,
- "patch": 1
- }
- },
- "gitaly": {
- "version": "12.10.0-rc1-93-g40980d40",
- "servers": 56,
- "clusters": 14,
- "filesystems": [
- "EXT_2_3_4"
- ]
- },
- "gitlab_pages": {
- "enabled": true,
- "version": "1.17.0"
- },
- "container_registry_server": {
- "vendor": "gitlab",
- "version": "2.9.1-gitlab"
- },
- "database": {
- "adapter": "postgresql",
- "version": "9.6.15",
- "pg_system_id": 6842684531675334351,
- "flavor": "Cloud SQL for PostgreSQL"
- },
- "analytics_unique_visits": {
- "g_analytics_contribution": 999,
- ...
- },
- "usage_activity_by_stage": {
- "configure": {
- "project_clusters_enabled": 999,
- ...
- },
- "create": {
- "merge_requests": 999,
- ...
- },
- "manage": {
- "events": 999,
- ...
- },
- "monitor": {
- "clusters": 999,
- ...
- },
- "package": {
- "projects_with_packages": 999
- },
- "plan": {
- "issues": 999,
- ...
- },
- "release": {
- "deployments": 999,
- ...
- },
- "secure": {
- "user_container_scanning_jobs": 999,
- ...
- },
- "verify": {
- "ci_builds": 999,
- ...
- }
- },
- "usage_activity_by_stage_monthly": {
- "configure": {
- "project_clusters_enabled": 999,
- ...
- },
- "create": {
- "merge_requests": 999,
- ...
- },
- "manage": {
- "events": 999,
- ...
- },
- "monitor": {
- "clusters": 999,
- ...
- },
- "package": {
- "projects_with_packages": 999
- },
- "plan": {
- "issues": 999,
- ...
- },
- "release": {
- "deployments": 999,
- ...
- },
- "secure": {
- "user_container_scanning_jobs": 999,
- ...
- },
- "verify": {
- "ci_builds": 999,
- ...
- }
- },
- "topology": {
- "duration_s": 0.013836685999194742,
- "application_requests_per_hour": 4224,
- "query_apdex_weekly_average": 0.996,
- "failures": [],
- "nodes": [
- {
- "node_memory_total_bytes": 33269903360,
- "node_memory_utilization": 0.35,
- "node_cpus": 16,
- "node_cpu_utilization": 0.2,
- "node_uname_info": {
- "machine": "x86_64",
- "sysname": "Linux",
- "release": "4.19.76-linuxkit"
- },
- "node_services": [
- {
- "name": "web",
- "process_count": 16,
- "process_memory_pss": 233349888,
- "process_memory_rss": 788220927,
- "process_memory_uss": 195295487,
- "server": "puma"
- },
- {
- "name": "sidekiq",
- "process_count": 1,
- "process_memory_pss": 734080000,
- "process_memory_rss": 750051328,
- "process_memory_uss": 731533312
- },
- ...
- ],
- ...
- },
- ...
- ]
- }
-}
-```
-
-## Notable changes
-
-In GitLab 14.6, [`flavor`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75587) was added to try to detect the underlying managed database variant.
-Possible values are "Amazon Aurora PostgreSQL", "PostgreSQL on Amazon RDS", "Cloud SQL for PostgreSQL",
-"Azure Database for PostgreSQL - Flexible Server", or "null".
-
-In GitLab 13.5, `pg_system_id` was added to send the [PostgreSQL system identifier](https://www.2ndquadrant.com/en/blog/support-for-postgresqls-system-identifier-in-barman/).
-
-## Export Service Ping data
-
-Rake tasks exist to export Service Ping data in different formats.
-
-- The Rake tasks export the raw SQL queries for `count`, `distinct_count`, `sum`.
-- The Rake tasks export the Redis counter class or the line of the Redis block for `redis_usage_data`.
-- The Rake tasks calculate the `alt_usage_data` metrics.
-
-In the home directory of your local GitLab installation run the following Rake tasks for the YAML and JSON versions respectively:
-
-```shell
-# for YAML export of SQL queries
-bin/rake gitlab:usage_data:dump_sql_in_yaml
-
-# for JSON export of SQL queries
-bin/rake gitlab:usage_data:dump_sql_in_json
-
-# for JSON export of Non SQL data
-bin/rake gitlab:usage_data:dump_non_sql_in_json
-
-# You may pipe the output into a file
-bin/rake gitlab:usage_data:dump_sql_in_yaml > ~/Desktop/usage-metrics-2020-09-02.yaml
-```
-
-## Generate Service Ping
-
-To generate Service Ping, use [Teleport](https://goteleport.com/docs/) or a detached screen session on a remote server.
-
-### Triggering
-
-#### Trigger Service Ping with Teleport
-
-1. Request temporary [access](https://gitlab.com/gitlab-com/runbooks/-/blob/master/docs/teleport/Connect_to_Rails_Console_via_Teleport.md#how-to-use-teleport-to-connect-to-rails-console) to the required environment.
-1. After your approval is issued, [access the Rails console](https://gitlab.com/gitlab-com/runbooks/-/blob/master/docs/teleport/Connect_to_Rails_Console_via_Teleport.md#access-approval).
-1. Run `GitlabServicePingWorker.new.perform('triggered_from_cron' => false)`.
-
-#### Trigger Service Ping with a detached screen session
-
-1. Connect to bastion with agent forwarding:
-
- ```shell
- ssh -A lb-bastion.gprd.gitlab.com
- ```
-
-1. Create named screen:
-
- ```shell
- screen -S <username>_usage_ping_<date>
- ```
-
-1. Connect to console host:
-
- ```shell
- ssh $USER-rails@console-01-sv-gprd.c.gitlab-production.internal
- ```
-
-1. Run:
-
- ```shell
- GitlabServicePingWorker.new.perform('triggered_from_cron' => false)
- ```
-
-1. To detach from screen, press `ctrl + A`, `ctrl + D`.
-1. Exit from bastion:
-
- ```shell
- exit
- ```
-
-1. Get the metrics duration from logs:
-
-Search in Google Console logs for `time_elapsed`. [Query example](https://cloudlogging.app.goo.gl/nWheZvD8D3nWazNe6).
-
-### Verification (After approx 30 hours)
-
-#### Verify with Teleport
-
-1. Follow [the steps](https://gitlab.com/gitlab-com/runbooks/-/blob/master/docs/teleport/Connect_to_Rails_Console_via_Teleport.md#how-to-use-teleport-to-connect-to-rails-console) to request a new access to the required environment and connect to the Rails console
-1. Check the last payload in `raw_usage_data` table: `RawUsageData.last.payload`
-1. Check the when the payload was sent: `RawUsageData.last.sent_at`
-
-#### Verify using detached screen session
-
-1. Reconnect to bastion:
-
- ```shell
- ssh -A lb-bastion.gprd.gitlab.com
- ```
-
-1. Find your screen session:
-
- ```shell
- screen -ls
- ```
-
-1. Attach to your screen session:
-
- ```shell
- screen -x 14226.mwawrzyniak_usage_ping_2021_01_22
- ```
-
-1. Check the last payload in `raw_usage_data` table:
-
- ```shell
- RawUsageData.last.payload
- ```
-
-1. Check the when the payload was sent:
-
- ```shell
- RawUsageData.last.sent_at
- ```
-
-### Skip database write operations
-
-To skip database write operations, DevOps report creation, and storage of usage data payload, pass an optional argument:
-
-```shell
-skip_db_write:
-GitlabServicePingWorker.new.perform('triggered_from_cron' => false, 'skip_db_write' => true)
-```
-
-## Monitoring
-
-Service Ping reporting process state is monitored with [internal SiSense dashboard](https://app.periscopedata.com/app/gitlab/968489).
-
-## Related topics
-
-- [Analytics Instrumentation Guide](https://about.gitlab.com/handbook/product/analytics-instrumentation-guide/)
-- [Snowplow Guide](../snowplow/index.md)
-- [Analytics Instrumentation Direction](https://about.gitlab.com/direction/analytics/analytics-instrumentation/)
-- [Data Analysis Process](https://about.gitlab.com/handbook/business-technology/data-team/#data-analysis-process/)
-- [Data for Product Managers](https://about.gitlab.com/handbook/business-technology/data-team/programs/data-for-product-managers/)
-- [Data Infrastructure](https://about.gitlab.com/handbook/business-technology/data-team/platform/infrastructure/)
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html
diff --git a/doc/development/service_ping/metrics_dictionary.md b/doc/development/service_ping/metrics_dictionary.md
index d53400276d0..fecab4916f5 100644
--- a/doc/development/service_ping/metrics_dictionary.md
+++ b/doc/development/service_ping/metrics_dictionary.md
@@ -1,334 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/metrics_dictionary.md'
+remove_date: '2023-08-20'
---
-# Metrics Dictionary Guide
+This document was moved to [another location](../internal_analytics/service_ping/metrics_dictionary.md).
-[Service Ping](index.md) metrics are defined in individual YAML files definitions from which the
-[Metrics Dictionary](https://metrics.gitlab.com/) is built. Currently, the metrics dictionary is built automatically once a day. When a change to a metric is made in a YAML file, you can see the change in the dictionary within 24 hours.
-This guide describes the 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 Service Ping. All metrics *must*:
-
-- Comply with the defined [JSON schema](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/schema.json).
-- Have a unique `key_path` .
-- Have an owner.
-
-All metrics are stored in YAML files:
-
-- [`config/metrics`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/config/metrics)
-
-WARNING:
-Only metrics with a metric definition YAML and whose status is not `removed` are added to the Service Ping JSON payload.
-
-Each metric is defined in a separate YAML file consisting of a number of fields:
-
-| Field | Required | Additional information |
-|---------------------|----------|----------------------------------------------------------------|
-| `key_path` | yes | JSON key path for the metric, location in Service Ping payload. |
-| `name` (deprecated) | no | Metric name suggestion. Does not have any impact on the Service Ping payload, only serves as documentation. |
-| `description` | yes | |
-| `product_section` | yes | The [section](https://gitlab.com/gitlab-com/www-gitlab-com/-/blob/master/data/sections.yml). |
-| `product_stage` | yes | The [stage](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/stages.yml) for the metric. |
-| `product_group` | yes | The [group](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/stages.yml) that owns the metric. |
-| `value_type` | yes | `string`; one of [`string`, `number`, `boolean`, `object`](https://json-schema.org/understanding-json-schema/reference/type.html). |
-| `status` | yes | `string`; [status](#metric-statuses) of the metric, may be set to `active`, `removed`, `broken`. |
-| `time_frame` | yes | `string`; may be set to a value like `7d`, `28d`, `all`, `none`. |
-| `data_source` | yes | `string`; may be set to a value like `database`, `redis`, `redis_hll`, `prometheus`, `system`, `license`. |
-| `data_category` | yes | `string`; [categories](#data-category) of the metric, may be set to `operational`, `optional`, `subscription`, `standard`. The default value is `optional`.|
-| `instrumentation_class` | yes | `string`; [the class that implements the metric](metrics_instrumentation.md). |
-| `distribution` | yes | `array`; may be set to one of `ce, ee` or `ee`. The [distribution](https://about.gitlab.com/handbook/marketing/brand-and-product-marketing/product-and-solution-marketing/tiers/#definitions) where the tracked feature is available. |
-| `performance_indicator_type` | no | `array`; may be set to one of [`gmau`, `smau`, `paid_gmau`, `umau` or `customer_health_score`](https://about.gitlab.com/handbook/business-technology/data-team/data-catalog/xmau-analysis/). |
-| `tier` | yes | `array`; may contain one or a combination of `free`, `premium` or `ultimate`. The [tier](https://about.gitlab.com/handbook/marketing/brand-and-product-marketing/product-and-solution-marketing/tiers/#definitions) where the tracked feature is available. This should be verbose and contain all tiers where a metric is available. |
-| `milestone` | yes | The milestone when the metric is introduced and when it's available to self-managed instances with the official GitLab release. |
-| `milestone_removed` | no | The milestone when the metric is removed. |
-| `introduced_by_url` | no | The URL to the merge request that introduced the metric to be available for self-managed instances. |
-| `removed_by_url` | no | The URL to the merge request that removed the metric. |
-| `repair_issue_url` | no | The URL of the issue that was created to repair a metric with a `broken` status. |
-| `options` | no | `object`: options information needed to calculate the metric value. |
-| `skip_validation` | no | This should **not** be set. [Used for imported metrics until we review, update and make them valid](https://gitlab.com/groups/gitlab-org/-/epics/5425). |
-
-### Metric `key_path`
-
-The `key_path` of the metric is the location in the JSON Service Ping payload.
-
-The `key_path` could be composed from multiple parts separated by `.` and it must be unique.
-
-We recommend to add the metric in one of the top-level keys:
-
-- `settings`: for settings related metrics.
-- `counts_weekly`: for counters that have data for the most recent 7 days.
-- `counts_monthly`: for counters that have data for the most recent 28 days.
-- `counts`: for counters that have data for all time.
-
-NOTE:
-We can't control what the metric's `key_path` is, because some of them are generated dynamically in `usage_data.rb`.
-For example, see [Redis HLL metrics](implement.md#redis-hll-counters).
-
-### Metric name (deprecated)
-
-WARNING:
-This feature was deprecated in GitLab 16.1
-and is planned for [removal](https://gitlab.com/gitlab-org/gitlab/-/issues/411602) in 16.2.
-
-To improve metric discoverability by a wider audience, each metric with
-instrumentation added at an appointed `key_path` receives a `name` attribute
-filled with the name suggestion, corresponding to the metric `data_source` and instrumentation.
-Metric name suggestions can contain two types of elements:
-
-1. **User input prompts**: enclosed by angle brackets (`< >`), these pieces should be replaced or
- removed when you create a metrics YAML file.
-1. **Fixed suggestion**: plaintext parts generated according to well-defined algorithms.
- They are based on underlying instrumentation, and must not be changed.
-
-For a metric name to be valid, it must not include any prompt, and fixed suggestions
-must not be changed.
-
-#### Generate a metric name suggestion (deprecated)
-
-WARNING:
-This feature was deprecated in GitLab 16.1
-and is planned for [removal](https://gitlab.com/gitlab-org/gitlab/-/issues/411602) in 16.2.
-
-The metric YAML generator can suggest a metric name for you.
-To generate a metric name suggestion, first instrument the metric at the provided `key_path`.
-Then, generate the metric's YAML definition and
-return to the instrumentation and update it.
-
-1. Add the metric instrumentation class to `lib/gitlab/usage/metrics/instrumentations/`.
-1. Add the metric logic in the instrumentation class.
-1. Run the [metrics YAML generator](metrics_dictionary.md#create-a-new-metric-definition).
-1. Use the metric name suggestion to select a suitable metric name.
-1. Update the metric's YAML definition with the correct `key_path`.
-
-### Metric statuses
-
-Metric definitions can have one of the following statuses:
-
-- `active`: Metric is used and reports data.
-- `broken`: Metric reports broken data (for example, -1 fallback), or does not report data at all. A metric marked as `broken` must also have the `repair_issue_url` attribute.
-- `removed`: Metric was removed, but it may appear in Service Ping payloads sent from instances running on older versions of GitLab.
-
-### Metric `value_type`
-
-Metric definitions can have one of the following values for `value_type`:
-
-- `boolean`
-- `number`
-- `string`
-- `object`: A metric with `value_type: object` must have `value_json_schema` with a link to the JSON schema for the object.
-In general, we avoid complex objects and prefer one of the `boolean`, `number`, or `string` value types.
-An example of a metric that uses `value_type: object` is `topology` (`/config/metrics/settings/20210323120839_topology.yml`),
-which has a related schema in `/config/metrics/objects_schemas/topology_schema.json`.
-
-### Metric `time_frame`
-
-A metric's time frame is calculated based on the `time_frame` field and the `data_source` of the metric.
-For `redis_hll` metrics, the type of aggregation is also taken into consideration. In this context, the term "aggregation" refers to [chosen events data storage interval](implement.md#add-new-events), and is **NOT** related to the Aggregated Metrics feature.
-For more information about the aggregation type of each feature, see the [`common.yml` file](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data_counters/known_events/common.yml). Weeks run from Monday to Sunday.
-
-| data_source | time_frame | aggregation | Description |
-|------------------------|------------|----------------|-------------------------------------------------|
-| any | `none` | not applicable | A type of data that’s not tracked over time, such as settings and configuration information |
-| `database` | `all` | not applicable | The whole time the metric has been active (all-time interval) |
-| `database` | `7d` | not applicable | 9 days ago to 2 days ago |
-| `database` | `28d` | not applicable | 30 days ago to 2 days ago |
-| `redis` | `all` | not applicable | The whole time the metric has been active (all-time interval) |
-| `redis_hll` | `7d` | `daily` | Most recent 7 complete days |
-| `redis_hll` | `7d` | `weekly` | Most recent complete week |
-| `redis_hll` | `28d` | `daily` | Most recent 28 complete days |
-| `redis_hll` | `28d` | `weekly` | Most recent 4 complete weeks |
-
-### Data category
-
-We use the following categories to classify a metric:
-
-- `operational`: Required data for operational purposes.
-- `optional`: Default value for a metric. Data that is optional to collect. This can be [enabled or disabled](../../user/admin_area/settings/usage_statistics.md#enable-or-disable-usage-statistics) in the Admin Area.
-- `subscription`: Data related to licensing.
-- `standard`: Standard set of identifiers that are included when collecting data.
-
-An aggregate metric is a metric that is the sum of two or more child metrics. Service Ping uses the data category of
-the aggregate metric to determine whether or not the data is included in the reported Service Ping payload.
-
-### Metric name suggestion examples (deprecated)
-
-WARNING:
-This feature was deprecated in GitLab 16.1
-and is planned for [removal](https://gitlab.com/gitlab-org/gitlab/-/issues/411602) in 16.2.
-
-#### Metric with `data_source: database`
-
-For a metric instrumented with SQL:
-
-```sql
-SELECT COUNT(DISTINCT user_id) FROM clusters WHERE clusters.management_project_id IS NOT NULL
-```
-
-- **Suggested name**: `count_distinct_user_id_from_<adjective describing: '(clusters.management_project_id IS NOT NULL)'>_clusters`
-- **Prompt**: `<adjective describing: '(clusters.management_project_id IS NOT NULL)'>`
- should be replaced with an adjective that best represents filter conditions, such as `project_management`
-- **Final metric name**: For example, `count_distinct_user_id_from_project_management_clusters`
-
-For metric instrumented with SQL:
-
-```sql
-SELECT COUNT(DISTINCT clusters.user_id)
-FROM clusters_applications_helm
-INNER JOIN clusters ON clusters.id = clusters_applications_helm.cluster_id
-WHERE clusters_applications_helm.status IN (3, 5)
-```
-
-- **Suggested name**: `count_distinct_user_id_from_<adjective describing: '(clusters_applications_helm.status IN (3, 5))'>_clusters_<with>_<adjective describing: '(clusters_applications_helm.status IN (3, 5))'>_clusters_applications_helm`
-- **Prompt**: `<adjective describing: '(clusters_applications_helm.status IN (3, 5))'>`
- should be replaced with an adjective that best represents filter conditions
-- **Final metric name**: `count_distinct_user_id_from_clusters_with_available_clusters_applications_helm`
-
-In the previous example, the prompt is irrelevant, and user can remove it. The second
-occurrence corresponds with the `available` scope defined in `Clusters::Concerns::ApplicationStatus`.
-It can be used as the right adjective to replace prompt.
-
-The `<with>` represents a suggested conjunction for the suggested name of the joined relation.
-The person documenting the metric can use it by either:
-
-- Removing the surrounding `<>`.
-- Using a different conjunction, such as `having` or `including`.
-
-#### Metric with `data_source: redis` or `redis_hll`
-
-For metrics instrumented with a Redis-based counter, the suggested name includes
-only the single prompt to be replaced by the person working with metrics YAML.
-
-- **Prompt**: `<please fill metric name, suggested format is: {subject}_{verb}{ing|ed}_{object} eg: users_creating_epics or merge_requests_viewed_in_single_file_mode>`
-- **Final metric name**: We suggest the metric name should follow the format of
- `{subject}_{verb}{ing|ed}_{object}`, such as `user_creating_epics`, `users_triggering_security_scans`,
- or `merge_requests_viewed_in_single_file_mode`
-
-#### Metric with `data_source: prometheus` or `system`
-
-For metrics instrumented with Prometheus or coming from the operating system,
-the suggested name includes only the single prompt by person working with metrics YAML.
-
-- **Prompt**: `<please fill metric name>`
-- **Final metric name**: Due to the variety of cases that can apply to this kind of metric,
- no naming convention exists. Each person instrumenting a metric should use their
- best judgment to come up with a descriptive name.
-
-### Example YAML 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
-key_path: uuid
-description: GitLab instance unique identifier
-product_section: analytics
-product_stage: analytics
-product_group: analytics_instrumentation
-value_type: string
-status: active
-milestone: 9.1
-instrumentation_class: UuidMetric
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/1521
-time_frame: none
-data_source: database
-distribution:
-- ce
-- ee
-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 files include a timestamp prefix in ISO 8601 format.
-
-The generator takes a list of key paths and 3 options as arguments. It creates metric YAML definitions in the 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`.
-- `--class_name=CLASS_NAME` Indicates the instrumentation class. For example `UsersCreatingIssuesMetric`, `UuidMetric`
-
-**Single metric example**
-
-```shell
-bundle exec rails generate gitlab:usage_metric_definition counts.issues --dir=7d --class_name=CountIssues
-// Creates 1 file
-// create config/metrics/counts_7d/issues.yml
-```
-
-**Multiple metrics example**
-
-```shell
-bundle exec rails generate gitlab:usage_metric_definition counts.issues counts.users --dir=7d --class_name=CountUsersCreatingIssues
-// Creates 2 files
-// create config/metrics/counts_7d/issues.yml
-// create config/metrics/counts_7d/users.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 --class_name=CountUsersCreatingIssues
-// Creates 1 file
-// create ee/config/metrics/counts_7d/issues.yml
-```
-
-### Metrics added dynamic to Service Ping payload
-
-The [Redis HLL metrics](implement.md#known-events-are-added-automatically-in-service-data-payload) are added automatically to Service Ping payload.
-
-A YAML metric definition is required for each metric. A dedicated generator is provided to create metric definitions for Redis HLL events.
-
-The generator takes `category` and `events` arguments, as the root key is `redis_hll_counters`, and creates two metric definitions for each of the events (for weekly and monthly time frames):
-
-**Single metric example**
-
-```shell
-bundle exec rails generate gitlab:usage_metric_definition:redis_hll issues count_users_closing_issues
-// Creates 2 files
-// create config/metrics/counts_7d/count_users_closing_issues_weekly.yml
-// create config/metrics/counts_28d/count_users_closing_issues_monthly.yml
-```
-
-**Multiple metrics example**
-
-```shell
-bundle exec rails generate gitlab:usage_metric_definition:redis_hll issues count_users_closing_issues count_users_reopening_issues
-// Creates 4 files
-// create config/metrics/counts_7d/count_users_closing_issues_weekly.yml
-// create config/metrics/counts_28d/count_users_closing_issues_monthly.yml
-// create config/metrics/counts_7d/count_users_reopening_issues_weekly.yml
-// create config/metrics/counts_28d/count_users_reopening_issues_monthly.yml
-```
-
-To create a metric definition used in EE, add the `--ee` flag.
-
-```shell
-bundle exec rails generate gitlab:usage_metric_definition:redis_hll issues users_closing_issues --ee
-// Creates 2 files
-// create config/metrics/counts_7d/i_closed_weekly.yml
-// create config/metrics/counts_28d/i_closed_monthly.yml
-```
-
-## Metrics Dictionary
-
-[Metrics Dictionary is a separate application](https://gitlab.com/gitlab-org/analytics-section/analytics-instrumentation/metric-dictionary).
-
-All metrics available in Service Ping are in the [Metrics Dictionary](https://metrics.gitlab.com/).
-
-### Copy query to clipboard
-
-To check if a metric has data in Sisense, use the copy query to clipboard feature. This copies a query that's ready to use in Sisense. The query gets the last five service ping data for GitLab.com for a given metric. For information about how to check if a Service Ping metric has data in Sisense, see this [demo](https://www.youtube.com/watch?v=n4o65ivta48).
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html
diff --git a/doc/development/service_ping/metrics_instrumentation.md b/doc/development/service_ping/metrics_instrumentation.md
index b6ca773a572..5a4dfc325e2 100644
--- a/doc/development/service_ping/metrics_instrumentation.md
+++ b/doc/development/service_ping/metrics_instrumentation.md
@@ -1,478 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/metrics_instrumentation.md'
+remove_date: '2023-08-20'
---
-# Metrics instrumentation guide
+This document was moved to [another location](../internal_analytics/service_ping/metrics_instrumentation.md).
-This guide describes how to develop Service Ping metrics using metrics instrumentation.
-
-<i class="fa fa-youtube-play youtube" aria-hidden="true"></i>
-For a video tutorial, see the [Adding Service Ping metric via instrumentation class](https://youtu.be/p2ivXhNxUoY).
-
-## Nomenclature
-
-- **Instrumentation class**:
- - Inherits one of the metric classes: `DatabaseMetric`, `RedisMetric`, `RedisHLLMetric`, `NumbersMetric` or `GenericMetric`.
- - Implements the logic that calculates the value for a Service Ping metric.
-
-- **Metric definition**
- The Service Data metric YAML definition.
-
-- **Hardening**:
- Hardening a method is the process that ensures the method fails safe, returning a fallback value like -1.
-
-## How it works
-
-A metric definition has the [`instrumentation_class`](metrics_dictionary.md) field, which can be set to a class.
-
-The defined instrumentation class should inherit one of the existing metric classes: `DatabaseMetric`, `RedisMetric`, `RedisHLLMetric`, `NumbersMetric` or `GenericMetric`.
-
-The current convention is that a single instrumentation class corresponds to a single metric. On rare occasions, there are exceptions to that convention like [Redis metrics](#redis-metrics). To use a single instrumentation class for more than one metric, please reach out to one of the `@gitlab-org/analytics-section/analytics-instrumentation/engineers` members to consult about your case.
-
-Using the instrumentation classes ensures that metrics can fail safe individually, without breaking the entire
- process of Service Ping generation.
-
-We have built a domain-specific language (DSL) to define the metrics instrumentation.
-
-## Database metrics
-
-You can use database metrics to track data kept in the database, for example, a count of issues that exist on a given instance.
-
-- `operation`: Operations for the given `relation`, one of `count`, `distinct_count`, `sum`, and `average`.
-- `relation`: Assigns lambda that returns the `ActiveRecord::Relation` for the objects we want to perform the `operation`. The assigned lambda can accept up to one parameter. The parameter is hashed and stored under the `options` key in the metric definition.
-- `start`: Specifies the start value of the batch counting, by default is `relation.minimum(:id)`.
-- `finish`: Specifies the end value of the batch counting, by default is `relation.maximum(:id)`.
-- `cache_start_and_finish_as`: Specifies the cache key for `start` and `finish` values and sets up caching them. Use this call when `start` and `finish` are expensive queries that should be reused between different metric calculations.
-- `available?`: Specifies whether the metric should be reported. The default is `true`.
-- `timestamp_column`: Optionally specifies timestamp column for metric used to filter records for time constrained metrics. The default is `created_at`.
-
-[Example of a merge request that adds a database metric](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60022).
-
-```ruby
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class CountIssuesMetric < DatabaseMetric
- operation :count
-
- relation ->(options) { Issue.where(confidential: options[:confidential]) }
- end
- end
- end
- end
-end
-```
-
-### Ordinary batch counters Example
-
-```ruby
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class CountIssuesMetric < DatabaseMetric
- operation :count
-
- start { Issue.minimum(:id) }
- finish { Issue.maximum(:id) }
-
- relation { Issue }
- end
- end
- end
- end
-end
-```
-
-### Distinct batch counters Example
-
-```ruby
-# frozen_string_literal: true
-
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class CountUsersAssociatingMilestonesToReleasesMetric < DatabaseMetric
- operation :distinct_count, column: :author_id
-
- relation { Release.with_milestones }
-
- start { Release.minimum(:author_id) }
- finish { Release.maximum(:author_id) }
- end
- end
- end
- end
-end
-```
-
-### Sum Example
-
-```ruby
-# frozen_string_literal: true
-
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class JiraImportsTotalImportedIssuesCountMetric < DatabaseMetric
- operation :sum, column: :imported_issues_count
-
- relation { JiraImportState.finished }
- end
- end
- end
- end
-end
-```
-
-### Average Example
-
-```ruby
-# frozen_string_literal: true
-
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class CountIssuesWeightAverageMetric < DatabaseMetric
- operation :average, column: :weight
-
- relation { Issue }
- end
- end
- end
- end
-end
-```
-
-## Redis metrics
-
-You can use Redis metrics to track events not kept in the database, for example, a count of how many times the search bar has been used.
-
-[Example of a merge request that adds `Redis` metrics](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/103455).
-
-The `RedisMetric` class can only be used as the `instrumentation_class` for Redis metrics with simple counters classes (classes that only inherit `BaseCounter` and set `PREFIX` and `KNOWN_EVENTS` constants). In case the counter class has additional logic included in it, a new `instrumentation_class`, inheriting from `RedisMetric`, needs to be created. This new class needs to include the additional logic from the counter class.
-
-Required options:
-
-- `event`: the event name.
-- `prefix`: the value of the `PREFIX` constant used in the counter classes from the `Gitlab::UsageDataCounters` namespace.
-
-Count unique values for `source_code_pushes` event.
-
-```yaml
-time_frame: all
-data_source: redis
-instrumentation_class: RedisMetric
-options:
- event: pushes
- prefix: source_code
-```
-
-### Availability-restrained Redis metrics
-
-If the Redis metric should only be available in the report under some conditions, then you must specify these conditions in a new class that is a child of the `RedisMetric` class.
-
-```ruby
-# frozen_string_literal: true
-
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class MergeUsageCountRedisMetric < RedisMetric
- available? { Feature.enabled?(:merge_usage_data_missing_key_paths) }
- end
- end
- end
- end
-end
-```
-
-You must also use the class's name in the YAML setup.
-
-```yaml
-time_frame: all
-data_source: redis
-instrumentation_class: MergeUsageCountRedisMetric
-options:
- event: pushes
- prefix: source_code
-```
-
-## Redis HyperLogLog metrics
-
-You can use Redis HyperLogLog metrics to track events not kept in the database and incremented for unique values such as unique users,
-for example, a count of how many different users used the search bar.
-
-[Example of a merge request that adds a `RedisHLL` metric](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61685).
-
-Count unique values for `i_quickactions_approve` event.
-
-```yaml
-time_frame: 28d
-data_source: redis_hll
-instrumentation_class: RedisHLLMetric
-options:
- events:
- - i_quickactions_approve
-```
-
-### Availability-restrained Redis HyperLogLog metrics
-
-If the Redis HyperLogLog metric should only be available in the report under some conditions, then you must specify these conditions in a new class that is a child of the `RedisHLLMetric` class.
-
-```ruby
-# frozen_string_literal: true
-
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class MergeUsageCountRedisHLLMetric < RedisHLLMetric
- available? { Feature.enabled?(:merge_usage_data_missing_key_paths) }
- end
- end
- end
- end
-end
-```
-
-You must also use the class's name in the YAML setup.
-
-```yaml
-time_frame: 28d
-data_source: redis_hll
-instrumentation_class: MergeUsageCountRedisHLLMetric
-options:
- events:
- - i_quickactions_approve
-```
-
-## Aggregated metrics
-
-<div class="video-fallback">
- See the video from: <a href="https://www.youtube.com/watch?v=22LbYqHwtUQ">Product Intelligence Office Hours Oct 6th</a> for an aggregated metrics walk-through.
-</div>
-<figure class="video-container">
- <iframe src="https://www.youtube-nocookie.com/embed/22LbYqHwtUQ" frameborder="0" allowfullscreen> </iframe>
-</figure>
-
-The aggregated metrics feature provides insight into the number of data attributes, for example `pseudonymized_user_ids`, that occurred in a collection of events. For example, you can aggregate the number of users who perform multiple actions such as creating a new issue and opening
-a new merge request.
-
-You can use a YAML file to define your aggregated metrics. The following arguments are required:
-
-- `options.events`: List of event names to aggregate into metric data. All events in this list must
- use the same data source. Additional data source requirements are described in
- [Database sourced aggregated metrics](implement.md#database-sourced-aggregated-metrics) and
- [Redis sourced aggregated metrics](implement.md#redis-sourced-aggregated-metrics).
-- `options.aggregate.operator`: Operator that defines how the aggregated metric data is counted. Available operators are:
- - `OR`: Removes duplicates and counts all entries that triggered any of the listed events.
- - `AND`: Removes duplicates and counts all elements that were observed triggering all of the following events.
-- `options.aggregate.attribute`: Information pointing to the attribute that is being aggregated across events.
-- `time_frame`: One or more valid time frames. Use these to limit the data included in aggregated metrics to events within a specific date-range. Valid time frames are:
- - `7d`: The last 7 days of data.
- - `28d`: The last 28 days of data.
- - `all`: All historical data, only available for `database` sourced aggregated metrics.
-- `data_source`: Data source used to collect all events data included in the aggregated metrics. Valid data sources are:
- - [`database`](implement.md#database-sourced-aggregated-metrics)
- - [`redis_hll`](implement.md#redis-sourced-aggregated-metrics)
-
-Refer to merge request [98206](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/98206) for an example of a merge request that adds an `AggregatedMetric` metric.
-
-Count unique `user_ids` that occurred in at least one of the events: `incident_management_alert_status_changed`,
-`incident_management_alert_assigned`, `incident_management_alert_todo`, `incident_management_alert_create_incident`.
-
-```yaml
-time_frame: 28d
-instrumentation_class: AggregatedMetric
-data_source: redis_hll
-options:
- aggregate:
- operator: OR
- attribute: user_id
- events:
- - `incident_management_alert_status_changed`
- - `incident_management_alert_assigned`
- - `incident_management_alert_todo`
- - `incident_management_alert_create_incident`
-```
-
-### Availability-restrained Aggregated metrics
-
-If the Aggregated metric should only be available in the report under specific conditions, then you must specify these conditions in a new class that is a child of the `AggregatedMetric` class.
-
-```ruby
-# frozen_string_literal: true
-
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class MergeUsageCountAggregatedMetric < AggregatedMetric
- available? { Feature.enabled?(:merge_usage_data_missing_key_paths) }
- end
- end
- end
- end
-end
-```
-
-You must also use the class's name in the YAML setup.
-
-```yaml
-time_frame: 28d
-instrumentation_class: MergeUsageCountAggregatedMetric
-data_source: redis_hll
-options:
- aggregate:
- operator: OR
- attribute: user_id
- events:
- - `incident_management_alert_status_changed`
- - `incident_management_alert_assigned`
- - `incident_management_alert_todo`
- - `incident_management_alert_create_incident`
-```
-
-## Numbers metrics
-
-- `operation`: Operations for the given `data` block. Currently we only support `add` operation.
-- `data`: a `block` which contains an array of numbers.
-- `available?`: Specifies whether the metric should be reported. The default is `true`.
-
-```ruby
-# frozen_string_literal: true
-
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class IssuesBoardsCountMetric < NumbersMetric
- operation :add
-
- data do |time_frame|
- [
- CountIssuesMetric.new(time_frame: time_frame).value,
- CountBoardsMetric.new(time_frame: time_frame).value
- ]
- end
- end
- end
- end
- end
- end
-end
-```
-
-You must also include the instrumentation class name in the YAML setup.
-
-```yaml
-time_frame: 28d
-instrumentation_class: IssuesBoardsCountMetric
-```
-
-## Generic metrics
-
-You can use generic metrics for other metrics, for example, an instance's database version. Observations type of data will always have a Generic metric counter type.
-
-- `value`: Specifies the value of the metric.
-- `available?`: Specifies whether the metric should be reported. The default is `true`.
-
-[Example of a merge request that adds a generic metric](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60256).
-
-```ruby
-module Gitlab
- module Usage
- module Metrics
- module Instrumentations
- class UuidMetric < GenericMetric
- value do
- Gitlab::CurrentSettings.uuid
- end
- end
- end
- end
- end
-end
-```
-
-## Support for instrumentation classes
-
-There is support for:
-
-- `count`, `distinct_count`, `estimate_batch_distinct_count`, `sum`, and `average` for [database metrics](#database-metrics).
-- [Redis metrics](#redis-metrics).
-- [Redis HLL metrics](#redis-hyperloglog-metrics).
-- `add` for [numbers metrics](#numbers-metrics).
-- [Generic metrics](#generic-metrics), which are metrics based on settings or configurations.
-
-There is no support for:
-
-- `add`, `histogram` for database metrics.
-
-You can [track the progress to support these](https://gitlab.com/groups/gitlab-org/-/epics/6118).
-
-## Create a new metric instrumentation class
-
-To create a stub instrumentation for a Service Ping metric, you can use a dedicated [generator](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/generators/gitlab/usage_metric_generator.rb):
-
-The generator takes the class name as an argument and the following options:
-
-- `--type=TYPE` Required. Indicates the metric type. It must be one of: `database`, `generic`, `redis`, `numbers`.
-- `--operation` Required for `database` & `numbers` type.
- - For `database` it must be one of: `count`, `distinct_count`, `estimate_batch_distinct_count`, `sum`, `average`.
- - For `numbers` it must be: `add`.
-- `--ee` Indicates if the metric is for EE.
-
-```shell
-rails generate gitlab:usage_metric CountIssues --type database --operation distinct_count
- create lib/gitlab/usage/metrics/instrumentations/count_issues_metric.rb
- create spec/lib/gitlab/usage/metrics/instrumentations/count_issues_metric_spec.rb
-```
-
-## Migrate Service Ping metrics to instrumentation classes
-
-This guide describes how to migrate a Service Ping metric from [`lib/gitlab/usage_data.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data.rb) or [`ee/lib/ee/gitlab/usage_data.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/ee/gitlab/usage_data.rb) to instrumentation classes.
-
-1. Choose the metric type:
-
-- [Database metric](#database-metrics)
-- [Redis HyperLogLog metrics](#redis-hyperloglog-metrics)
-- [Redis metric](#redis-metrics)
-- [Numbers metric](#numbers-metrics)
-- [Generic metric](#generic-metrics)
-
-1. Determine the location of instrumentation class: either under `ee` or outside `ee`.
-
-1. [Generate the instrumentation class file](#create-a-new-metric-instrumentation-class).
-
-1. Fill the instrumentation class body:
-
- - Add code logic for the metric. This might be similar to the metric implementation in `usage_data.rb`.
- - Add tests for the individual metric [`spec/lib/gitlab/usage/metrics/instrumentations/`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/lib/gitlab/usage/metrics/instrumentations).
- - Add tests for Service Ping.
-
-1. [Generate the metric definition file](metrics_dictionary.md#create-a-new-metric-definition).
-
-1. Remove the code from [`lib/gitlab/usage_data.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data.rb) or [`ee/lib/ee/gitlab/usage_data.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/ee/gitlab/usage_data.rb).
-
-1. Remove the tests from [`spec/lib/gitlab/usage_data.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/spec/lib/gitlab/usage_data_spec.rb) or [`ee/spec/lib/ee/gitlab/usage_data.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/spec/lib/ee/gitlab/usage_data_spec.rb).
-
-## Troubleshoot metrics
-
-Sometimes metrics fail for reasons that are not immediately clear. The failures can be related to performance issues or other problems.
-The following pairing session video gives you an example of an investigation in to a real-world failing metric.
-
-<div class="video-fallback">
- See the video from: <a href="https://www.youtube.com/watch?v=y_6m2POx2ug">Product Intelligence Office Hours Oct 27th</a> to learn more about the metrics troubleshooting process.
-</div>
-<figure class="video-container">
- <iframe src="https://www.youtube-nocookie.com/embed/y_6m2POx2ug" frameborder="0" allowfullscreen> </iframe>
-</figure>
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html
diff --git a/doc/development/service_ping/metrics_lifecycle.md b/doc/development/service_ping/metrics_lifecycle.md
index cc56863690c..520b18139ff 100644
--- a/doc/development/service_ping/metrics_lifecycle.md
+++ b/doc/development/service_ping/metrics_lifecycle.md
@@ -1,106 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/metrics_lifecycle.md'
+remove_date: '2023-08-20'
---
-# Service Ping metric lifecycle
+This document was moved to [another location](../internal_analytics/service_ping/metrics_lifecycle.md).
-The following guidelines explain the steps to follow at each stage of a metric's lifecycle.
-
-## Add a new metric
-
-Follow the [Implement Service Ping](implement.md) guide.
-
-## Change an existing metric
-
-WARNING:
-We want to **PREVENT** changes to the calculation logic or important attributes on any metric as this invalidates comparisons of the same metric across different versions of GitLab.
-
-If you change a metric, you have to consider that not all instances of GitLab are running on the newest version. Old instances will still report the old version of the metric.
-Additionally, a metric's reported numbers are primarily interesting compared to previously reported numbers.
-As a result, if you need to change one of the following parts of a metric, you need to add a new metric instead. It's your choice whether to keep the old metric alongside the new one or [remove it](#remove-a-metric).
-
-- **calculation logic**: This means any changes that can produce a different value than the previous implementation
-- **YAML attributes**: The following attributes are directly used for analysis or calculation: `key_path`, `time_frame`, `value_type`, `data_source`.
-
-If you change the `performance_indicator_type` attribute of a metric or think your case needs an exception from the outlined rules then please notify the Customer Success Ops team (`@csops-team`), Analytics Engineers (`@gitlab-data/analytics-engineers`), and Product Analysts (`@gitlab-data/product-analysts`) teams by `@` mentioning those groups in a comment on the merge request or issue.
-
-You can change any other attributes without impact to the calculation or analysis. See [this video tutorial](https://youtu.be/bYf3c01KCls) for help updating metric attributes.
-
-Currently, the [Metrics Dictionary](https://metrics.gitlab.com/) is built automatically once a day. You can see the change in the dictionary within 24 hours when you change the metric's YAML file.
-
-## Remove a metric
-
-WARNING:
-If a metric is not used in Sisense or any other system after 6 months, the
-Analytics Instrumentation team marks it as inactive and assigns it to the group owner for review.
-
-We are working on automating this process. See [this epic](https://gitlab.com/groups/gitlab-org/-/epics/8988) for details.
-
-Analytics Instrumentation removes metrics from Service Ping if they are not used in any Sisense dashboard.
-
-For an example of the metric removal process, see this [example issue](https://gitlab.com/gitlab-org/gitlab/-/issues/388236).
-
-To remove a metric:
-
-1. Create an issue for removing the metric if none exists yet. The issue needs to outline why the metric should be deleted. You can use this issue to document the removal process.
-
-1. Verify the metric is not used to calculate the conversational index. The
- conversational index is a measure that reports back to self-managed instances
- to inform administrators of the progress of DevOps adoption for the instance.
-
- You can check
- [`CalculateConvIndexService`](https://gitlab.com/gitlab-services/version-gitlab-com/-/blob/master/app/services/calculate_conv_index_service.rb)
- to view the metrics that are used. The metrics are represented
- as the keys that are passed as a field argument into the `get_value` method.
-
-1. Verify that removing the metric from the Service Ping payload does not cause
- errors in [Version App](https://gitlab.com/gitlab-services/version-gitlab-com)
- when the updated payload is collected and processed. Version App collects
- and persists all Service Ping reports. To verify Service Ping processing in your local development environment, follow this [guide](https://www.youtube.com/watch?v=FS5emplabRU).
- Alternatively, you can modify [fixtures](https://gitlab.com/gitlab-services/version-gitlab-com/-/blob/master/spec/support/usage_data_helpers.rb#L540)
- used to test the [`UsageDataController#create`](https://gitlab.com/gitlab-services/version-gitlab-com/-/blob/3760ef28/spec/controllers/usage_data_controller_spec.rb#L75)
- endpoint, and assure that test suite does not fail when metric that you wish to remove is not included into test payload.
-
-1. Remove data from Redis
-
- For [Ordinary Redis](implement.md#ordinary-redis-counters) counters remove data stored in Redis.
-
- - Add a migration to remove the data from Redis for the related Redis keys. For more details, see [this MR example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82604/diffs).
-
-1. Create an issue in the
- [GitLab Data Team project](https://gitlab.com/gitlab-data/analytics/-/issues).
- Ask for confirmation that the metric is not referred to in any SiSense dashboards and
- can be safely removed from Service Ping. Use this
- [example issue](https://gitlab.com/gitlab-data/analytics/-/issues/15266) for guidance.
-
-1. Notify the Customer Success Ops team (`@csops-team`), Analytics Engineers (`@gitlab-data/analytics-engineers`), and Product Analysts (`@gitlab-data/product-analysts`) by `@` mentioning those groups in a comment in the issue from step 1 regarding the deletion of the metric.
- Many Service Ping metrics are relied upon for health score and XMAU reporting and unexpected changes to those metrics could break reporting.
-
-1. After you verify the metric can be safely removed,
- update the attributes of the metric's YAML definition:
-
- - Set the `status:` to `removed`.
- - Set `removed_by_url:` to the URL of the MR removing the metric
- - Set `milestone_removed:` to the number of the
- milestone in which the metric was removed.
-
- Do not remove the metric's YAML definition altogether. Some self-managed
- instances might not immediately update to the latest version of GitLab, and
- therefore continue to report the removed metric. The Analytics Instrumentation team
- requires a record of all removed metrics to identify and filter them.
-
- For example please take a look at this [merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60149/diffs#b01f429a54843feb22265100c0e4fec1b7da1240_10_10).
-
-1. After you verify the metric can be safely removed,
- remove the metric's instrumentation from
- [`lib/gitlab/usage_data.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data.rb)
- or
- [`ee/lib/ee/gitlab/usage_data.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/ee/gitlab/usage_data.rb).
-
- For example please take a look at this [merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60149/diffs#6335dc533bd21df26db9de90a02dd66278c2390d_167_167).
-
-1. Remove any other records related to the metric:
- - The feature flag YAML file at [`config/feature_flags/*/*.yaml`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/config/feature_flags).
- - The entry in the known events YAML file at [`lib/gitlab/usage_data_counters/known_events/*.yaml`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/lib/gitlab/usage_data_counters/known_events).
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html
diff --git a/doc/development/service_ping/performance_indicator_metrics.md b/doc/development/service_ping/performance_indicator_metrics.md
index d7811c52bb1..eda7224732d 100644
--- a/doc/development/service_ping/performance_indicator_metrics.md
+++ b/doc/development/service_ping/performance_indicator_metrics.md
@@ -1,16 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/performance_indicator_metrics.md'
+remove_date: '2023-08-20'
---
-# Performance Indicator Metrics guide
+This document was moved to [another location](../internal_analytics/service_ping/performance_indicator_metrics.md).
-This guide describes how to use metrics definitions to define [performance indicator](https://about.gitlab.com/handbook/product/analytics-instrumentation-guide/#implementing-product-performance-indicators) metrics.
-
-To use a metric definition to manage a performance indicator:
-
-1. Create a merge request that includes related changes.
-1. Use labels `~"analytics instrumentation"`, `"~Data Warehouse::Impact Check"`.
-1. Update the metric definition `performance_indicator_type` [field](metrics_dictionary.md#metrics-definition-and-validation).
-1. Create an issue in GitLab Product Data Insights project with the [PI Chart Help template](https://gitlab.com/gitlab-data/product-analytics/-/issues/new?issuable_template=PI%20Chart%20Help) to have the new metric visualized.
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html
diff --git a/doc/development/service_ping/review_guidelines.md b/doc/development/service_ping/review_guidelines.md
index 71c16820e23..d5805f615e2 100644
--- a/doc/development/service_ping/review_guidelines.md
+++ b/doc/development/service_ping/review_guidelines.md
@@ -1,80 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/review_guidelines.md'
+remove_date: '2023-08-20'
---
-# Service Ping review guidelines
+This document was moved to [another location](../internal_analytics/service_ping/review_guidelines.md).
-This page includes introductory material for a
-[Analytics Instrumentation](https://about.gitlab.com/handbook/engineering/development/analytics/analytics-instrumentation/)
-review, and is specific to Service Ping related reviews. For broader advice and
-general best practices for code reviews, refer to our [code review guide](../code_review.md).
-
-## Resources for reviewers
-
-- [Service Ping Guide](index.md)
-- [Metrics Dictionary](https://metrics.gitlab.com/)
-
-## Review process
-
-We recommend a Analytics Instrumentation review when a merge request (MR) touches
-any of the following Service Ping files:
-
-- `usage_data*` files.
-- The Metrics Dictionary, including files in:
- - [`config/metrics`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/config/metrics).
- - [`ee/config/metrics`](https://gitlab.com/gitlab-org/gitlab/-/tree/master/ee/config/metrics).
- - [`schema.json`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/schema.json).
-- Analytics Instrumentation tooling. For example,
- [`Gitlab::UsageMetricDefinitionGenerator`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/generators/gitlab/usage_metric_definition_generator.rb)
-
-### Roles and process
-
-#### The merge request **author** should
-
-- Decide whether a Analytics Instrumentation review is needed. You can skip the Analytics Instrumentation
-review and remove the labels if the changes are not related to the Analytics Instrumentation domain and
-are regular backend changes.
-- If a Analytics Instrumentation review is needed, add the labels
- `~analytics instrumentation` and `~analytics instrumentation::review pending`.
-- For merge requests authored by Analytics Instrumentation team members:
- - Assign both the `~backend` and `~analytics instrumentation` reviews to another Analytics Instrumentation team member.
- - Assign the maintainer review to someone outside of the Analytics Instrumentation group.
-- Assign an
- [engineer](https://gitlab.com/groups/gitlab-org/analytics-section/analytics-instrumentation/engineers/-/group_members?with_inherited_permissions=exclude) from the Analytics Instrumentation team for a review.
-- Set the correct attributes in the metric's YAML definition:
- - `product_section`, `product_stage`, `product_group`
- - Provide a clear description of the metric.
-- Add a changelog [according to guidelines](../changelog.md).
-
-#### The Analytics Instrumentation **reviewer** should
-
-- Perform a first-pass review on the merge request and suggest improvements to the author.
-- Check the [metrics location](metrics_dictionary.md#metric-key_path) in
- the Service Ping JSON payload.
-- Add the `~database` label and ask for a [database review](../database_review.md) for
- metrics that are based on Database.
-- Add `~Data Warehouse::Impact Check` for any database metric that has a query change. Changes in queries can affect [data operations](https://about.gitlab.com/handbook/business-technology/data-team/how-we-work/triage/#gitlabcom-db-structure-changes).
-- For tracking using Redis HLL (HyperLogLog):
- - Check if a [feature flag is needed](implement.md#recommendations).
-- For a metric's YAML definition:
- - Check the metric's `description`.
- - Check the metric's `key_path`.
- - Check the `product_section`, `product_stage`, and `product_group` fields.
- Read the [stages file](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/data/stages.yml).
- - Check the file location. Consider the time frame, and if the file should be under `ee`.
- - Check the tiers.
-- If a metric was changed or removed: Make sure the MR author notified the Customer Success Ops team (`@csops-team`), Analytics Engineers (`@gitlab-data/analytics-engineers`), and Product Analysts (`@gitlab-data/product-analysts`) by `@` mentioning those groups in a comment on the issue for the MR and all of these groups have acknowledged the removal.
-- Metrics instrumentations
- - Recommend using metrics instrumentation for new metrics, [if possible](metrics_instrumentation.md#support-for-instrumentation-classes).
-- Approve the MR, and relabel the MR with `~"analytics instrumentation::approved"`.
-
-## Review workload distribution
-
-[Danger bot](../dangerbot.md) adds the list of changed Analytics Instrumentation files
-and pings the
-[`@gitlab-org/analytics-section/analytics-instrumentation/engineers`](https://gitlab.com/groups/gitlab-org/analytics-section/analytics-instrumentation/engineers/-/group_members?with_inherited_permissions=exclude) group for merge requests
-that are not drafts.
-
-Any of the Analytics Instrumentation engineers can be assigned for the Analytics Instrumentation review.
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html
diff --git a/doc/development/service_ping/troubleshooting.md b/doc/development/service_ping/troubleshooting.md
index 2706f570869..31b04c1a6bc 100644
--- a/doc/development/service_ping/troubleshooting.md
+++ b/doc/development/service_ping/troubleshooting.md
@@ -1,164 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/troubleshooting.md'
+remove_date: '2023-08-20'
---
-# Troubleshooting Service Ping
+This document was moved to [another location](../internal_analytics/service_ping/troubleshooting.md).
-## Service Ping Payload drop
-
-### Symptoms
-
-You will be alerted by the [Data team](https://about.gitlab.com/handbook/business-technology/data-team/) and their [Monte Carlo alerting](https://about.gitlab.com/handbook/business-technology/data-team/platform/monte-carlo/).
-
-### Locating the problem
-
-First you need to identify at which stage in Service Ping data pipeline the drop is occurring.
-
-Start at [Service Ping Health Dashboard](https://app.periscopedata.com/app/gitlab/968489) on Sisense.
-
-You can use [this query](https://gitlab.com/gitlab-org/gitlab/-/issues/347298#note_836685350) as an example, to start detecting when the drop started.
-
-### Troubleshoot the GitLab application layer
-
-For results about an investigation conducted into an unexpected drop in Service ping Payload events volume, see [this issue](https://gitlab.com/gitlab-data/analytics/-/issues/11071).
-
-### Troubleshoot VersionApp layer
-
-Check if the [export jobs](https://gitlab.com/gitlab-services/version-gitlab-com#data-export-using-pipeline-schedules) are successful.
-
-Check [Service Ping errors](https://app.periscopedata.com/app/gitlab/968489?widget=14609989&udv=0) in the [Service Ping Health Dashboard](https://app.periscopedata.com/app/gitlab/968489).
-
-### Troubleshoot Google Storage layer
-
-Check if the files are present in [Google Storage](https://console.cloud.google.com/storage/browser/cloudsql-gs-production-efd5e8-cloudsql-exports;tab=objects?project=gs-production-efd5e8&prefix=&forceOnObjectsSortingFiltering=false).
-
-### Troubleshoot the data warehouse layer
-
-Reach out to the [Data team](https://about.gitlab.com/handbook/business-technology/data-team/) to ask about current state of data warehouse. On their handbook page there is a [section with contact details](https://about.gitlab.com/handbook/business-technology/data-team/#how-to-connect-with-us).
-
-### Cannot disable Service Ping with the configuration file
-
-The method to disable Service Ping with the GitLab configuration file does not work in
-GitLab versions 9.3.0 to 13.12.3. To disable it, you must use the Admin Area in
-the GitLab UI instead. For more information, see
-[this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/333269).
-
-GitLab functionality and application settings cannot override or circumvent
-restrictions at the network layer. If Service Ping is blocked by your firewall,
-you are not impacted by this bug.
-
-#### Check if you are affected
-
-You can check if you were affected by this bug by using the Admin Area or by
-checking the configuration file of your GitLab instance:
-
-- Using the Admin Area:
-
- 1. On the left sidebar, expand the top-most chevron (**{chevron-down}**).
- 1. Select **Admin Area**.
- 1. On the left sidebar, select **Settings > Metrics and profiling**.
- 1. Expand **Usage statistics**.
- 1. Are you able to check or uncheck the checkbox to disable Service Ping?
-
- - If _yes_, your GitLab instance is not affected by this bug.
- - If you can't check or uncheck the checkbox, you are affected by this bug.
- See the steps on [how to fix this](#how-to-fix-the-cannot-disable-service-ping-bug).
-
-- Checking your GitLab instance configuration file:
-
- To check whether you're impacted by this bug, check your instance configuration
- settings. The configuration file in which Service Ping can be disabled depends
- on your installation and deployment method, but is typically one of the following:
-
- - `/etc/gitlab/gitlab.rb` for Linux package installations and Docker.
- - `charts.yaml` for GitLab Helm and cloud-native Kubernetes deployments.
- - `gitlab.yml` for GitLab installations from source.
-
- To check the relevant configuration file for strings that indicate whether
- Service Ping is disabled, you can use `grep`:
-
- ```shell
- # Linux package
- grep "usage_ping_enabled'\] = false" /etc/gitlab/gitlab.rb
-
- # Kubernetes charts
- grep "enableUsagePing: false" values.yaml
-
- # From source
- grep "usage_ping_enabled'\] = false" gitlab/config.yml
- ```
-
- If you see any output after running the relevant command, your GitLab instance
- may be affected by the bug. Otherwise, your instance is not affected.
-
-#### How to fix the "Cannot disable Service Ping" bug
-
-To work around this bug, you have two options:
-
-- [Update](../../update/index.md) to GitLab 13.12.4 or newer to fix this bug.
-- If you can't update to GitLab 13.12.4 or newer, enable Service Ping in the
- configuration file, then disable Service Ping in the UI. For example, if you're
- using the Linux package:
-
- 1. Edit `/etc/gitlab/gitlab.rb`:
-
- ```ruby
- gitlab_rails['usage_ping_enabled'] = true
- ```
-
- 1. Reconfigure GitLab:
-
- ```shell
- sudo gitlab-ctl reconfigure
- ```
-
- 1. On the left sidebar, expand the top-most chevron (**{chevron-down}**).
- 1. Select **Admin Area**.
- 1. On the left sidebar, select **Settings > Metrics and profiling**.
- 1. Expand **Usage statistics**.
- 1. Clear the **Enable Service Ping** checkbox.
- 1. Select **Save Changes**.
-
-## Generate Service Ping
-
-### Generate or get the cached Service Ping in rails console
-
-Use the following method in the [rails console](../../administration/operations/rails_console.md#starting-a-rails-console-session).
-
-```ruby
-Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values, cached: true)
-```
-
-### Generate a fresh new Service Ping
-
-Use the following method in the [rails console](../../administration/operations/rails_console.md#starting-a-rails-console-session).
-
-This also refreshes the cached Service Ping displayed in the Admin Area.
-
-```ruby
-Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)
-```
-
-### Generate and print
-
-Generates Service Ping data in JSON format.
-
-```shell
-gitlab-rake gitlab:usage_data:generate
-```
-
-Generates Service Ping data in YAML format:
-
-```shell
-gitlab-rake gitlab:usage_data:dump_sql_in_yaml
-```
-
-### Generate and send Service Ping
-
-Prints the metrics saved in `conversational_development_index_metrics`.
-
-```shell
-gitlab-rake gitlab:usage_data:generate_and_send
-```
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html
diff --git a/doc/development/service_ping/usage_data.md b/doc/development/service_ping/usage_data.md
index b3bdaedd60a..94ae90273d0 100644
--- a/doc/development/service_ping/usage_data.md
+++ b/doc/development/service_ping/usage_data.md
@@ -1,69 +1,11 @@
---
-stage: Analytics
-group: Analytics Instrumentation
-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
+redirect_to: '../internal_analytics/service_ping/usage_data.md'
+remove_date: '2023-08-20'
---
-# Usage Data Metrics guide
+This document was moved to [another location](../internal_analytics/service_ping/usage_data.md).
-This guide describes deprecated usage for metrics in `usage_data.rb`.
-
-NOTE:
-Implementing metrics direct in `usage_data.rb` is deprecated, We recommend you use [instrumentation classes](metrics_instrumentation.md).
-
-## Ordinary batch counters
-
-Simple count of a given `ActiveRecord_Relation`, does a non-distinct batch count, smartly reduces `batch_size`, and handles errors.
-Handles the `ActiveRecord::StatementInvalid` error.
-
-Method:
-
-```ruby
-count(relation, column = nil, batch: true, start: nil, finish: nil)
-```
-
-Arguments:
-
-- `relation` the ActiveRecord_Relation to perform the count
-- `column` the column to perform the count on, by default is the primary key
-- `batch`: default `true` to use batch counting
-- `start`: custom start of the batch counting to avoid complex min calculations
-- `end`: custom end of the batch counting to avoid complex min calculations
-
-Examples:
-
-```ruby
-count(User.active)
-count(::Clusters::Cluster.aws_installed.enabled, :cluster_id)
-count(::Clusters::Cluster.aws_installed.enabled, :cluster_id, start: ::Clusters::Cluster.minimum(:id), finish: ::Clusters::Cluster.maximum(:id))
-```
-
-## Distinct batch counters
-
-Distinct count of a given `ActiveRecord_Relation` on given column, a distinct batch count, smartly reduces `batch_size`, and handles errors.
-Handles the `ActiveRecord::StatementInvalid` error.
-
-Method:
-
-```ruby
-distinct_count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil)
-```
-
-Arguments:
-
-- `relation`: the ActiveRecord_Relation to perform the count
-- `column`: the column to perform the distinct count, by default is the primary key
-- `batch`: default `true` to use batch counting
-- `batch_size`: if none set it uses default value 10000 from `Gitlab::Database::BatchCounter`
-- `start`: custom start of the batch counting to avoid complex min calculations
-- `end`: custom end of the batch counting to avoid complex min calculations
-
-WARNING:
-Counting over non-unique columns can lead to performance issues. For more information, see the [iterating tables in batches](../database/iterating_tables_in_batches.md) guide.
-
-Examples:
-
-```ruby
-distinct_count(::Project, :creator_id)
-distinct_count(::Note.with_suggestions.where(time_period), :author_id, start: ::User.minimum(:id), finish: ::User.maximum(:id))
-```
+<!-- This redirect file can be deleted after <2023-08-20>. -->
+<!-- Redirects that point to other docs in the same project expire in three months. -->
+<!-- Redirects that point to docs in a different project or site (for example, link is not relative and starts with `https:`) expire in one year. -->
+<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/redirects.html