debian-mirror-gitlab/doc/api/usage_data.md

165 lines
5.4 KiB
Markdown
Raw Normal View History

2021-04-29 21:17:54 +05:30
---
2022-08-13 15:12:31 +05:30
stage: Analytics
2021-04-29 21:17:54 +05:30
group: Product Intelligence
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
type: reference, api
---
2021-09-30 23:02:18 +05:30
# Service Data API **(FREE SELF)**
2021-04-29 21:17:54 +05:30
2021-09-30 23:02:18 +05:30
The Service Data API is associated with [Service Ping](../development/service_ping/index.md).
2021-04-29 21:17:54 +05:30
## Export metric definitions as a single YAML file
2021-11-11 11:23:49 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57270) in GitLab 13.11.
2021-04-29 21:17:54 +05:30
2022-04-04 11:22:00 +05:30
Export all metric definitions as a single YAML file, similar to the [Metrics Dictionary](https://metrics.gitlab.com/), for easier importing.
2021-04-29 21:17:54 +05:30
```plaintext
GET /usage_data/metric_definitions
```
Example request:
```shell
curl "https://gitlab.example.com/api/v4/usage_data/metric_definitions"
```
Example response:
```yaml
---
- key_path: redis_hll_counters.search.i_search_paid_monthly
description: Calculated unique users to perform a search with a paid license enabled
by month
product_section: enablement
product_stage: enablement
2022-08-13 15:12:31 +05:30
product_group: global_search
2021-04-29 21:17:54 +05:30
product_category: global_search
value_type: number
2021-11-11 11:23:49 +05:30
status: active
2021-04-29 21:17:54 +05:30
time_frame: 28d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
...
```
2021-09-30 23:02:18 +05:30
## Export Service Ping SQL queries
2021-04-29 21:17:54 +05:30
2022-07-23 23:45:48 +05:30
This action is behind the `usage_data_queries_api` feature flag and is available only for the GitLab instance [Administrator](../user/permissions.md) users.
2021-04-29 21:17:54 +05:30
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57016) in GitLab 13.11.
2022-07-23 23:45:48 +05:30
> - [Deployed behind a feature flag](../user/feature_flags.md) named `usage_data_queries_api`, disabled by default.
2021-04-29 21:17:54 +05:30
2021-09-30 23:02:18 +05:30
Return all of the raw SQL queries used to compute Service Ping.
2021-04-29 21:17:54 +05:30
```plaintext
GET /usage_data/queries
```
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/usage_data/queries"
```
Example response:
```json
{
"recorded_at": "2021-03-23T06:31:21.267Z",
"uuid": null,
"hostname": "localhost",
"version": "13.11.0-pre",
"installation_type": "gitlab-development-kit",
"active_user_count": "SELECT COUNT(\"users\".\"id\") FROM \"users\" WHERE (\"users\".\"state\" IN ('active')) AND (\"users\".\"user_type\" IS NULL OR \"users\".\"user_type\" IN (NULL, 6, 4))",
"edition": "EE",
"license_md5": "c701acc03844c45366dd175ef7a4e19c",
2022-08-13 15:12:31 +05:30
"license_sha256": "366dd175ef7a4e19cc701acc03844c45366dd175ef7a4e19cc701acc03844c45",
2021-04-29 21:17:54 +05:30
"license_id": null,
"historical_max_users": 0,
"licensee": {
"Name": "John Doe1"
},
"license_user_count": null,
"license_starts_at": "1970-01-01",
"license_expires_at": "2022-02-23",
"license_plan": "starter",
"license_add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
},
"license_trial": null,
"license_subscription_id": "0000",
"license": {},
"settings": {
"ldap_encrypted_secrets_enabled": false,
"operating_system": "mac_os_x-11.2.2"
},
"counts": {
"assignee_lists": "SELECT COUNT(\"lists\".\"id\") FROM \"lists\" WHERE \"lists\".\"list_type\" = 3",
"boards": "SELECT COUNT(\"boards\".\"id\") FROM \"boards\"",
"ci_builds": "SELECT COUNT(\"ci_builds\".\"id\") FROM \"ci_builds\" WHERE \"ci_builds\".\"type\" = 'Ci::Build'",
"ci_internal_pipelines": "SELECT COUNT(\"ci_pipelines\".\"id\") FROM \"ci_pipelines\" WHERE (\"ci_pipelines\".\"source\" IN (1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13) OR \"ci_pipelines\".\"source\" IS NULL)",
"ci_external_pipelines": "SELECT COUNT(\"ci_pipelines\".\"id\") FROM \"ci_pipelines\" WHERE \"ci_pipelines\".\"source\" = 6",
"ci_pipeline_config_auto_devops": "SELECT COUNT(\"ci_pipelines\".\"id\") FROM \"ci_pipelines\" WHERE \"ci_pipelines\".\"config_source\" = 2",
"ci_pipeline_config_repository": "SELECT COUNT(\"ci_pipelines\".\"id\") FROM \"ci_pipelines\" WHERE \"ci_pipelines\".\"config_source\" = 1",
"ci_runners": "SELECT COUNT(\"ci_runners\".\"id\") FROM \"ci_runners\"",
...
```
## UsageDataNonSqlMetrics API
2022-07-23 23:45:48 +05:30
This action is behind the `usage_data_non_sql_metrics` feature flag and is available only for the GitLab instance [Administrator](../user/permissions.md) users.
2021-04-29 21:17:54 +05:30
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57050) in GitLab 13.11.
2022-07-23 23:45:48 +05:30
> - [Deployed behind a feature flag](../user/feature_flags.md), named `usage_data_non_sql_metrics`, disabled by default.
2021-04-29 21:17:54 +05:30
2021-09-30 23:02:18 +05:30
Return all non-SQL metrics data used in the Service ping.
2021-04-29 21:17:54 +05:30
Example request:
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/usage_data/non_sql_metrics"
```
Sample response:
```json
{
"recorded_at": "2021-03-26T07:04:03.724Z",
"uuid": null,
"hostname": "localhost",
"version": "13.11.0-pre",
"installation_type": "gitlab-development-kit",
"active_user_count": -3,
"edition": "EE",
"license_md5": "bb8cd0d8a6d9569ff3f70b8927a1f949",
2022-08-13 15:12:31 +05:30
"license_sha256": "366dd175ef7a4e19cc701acc03844c45366dd175ef7a4e19cc701acc03844c45",
2021-04-29 21:17:54 +05:30
"license_id": null,
"historical_max_users": 0,
"licensee": {
"Name": "John Doe1"
},
"license_user_count": null,
"license_starts_at": "1970-01-01",
"license_expires_at": "2022-02-26",
"license_plan": "starter",
"license_add_ons": {
"GitLab_FileLocks": 1,
"GitLab_Auditor_User": 1
},
"license_trial": null,
"license_subscription_id": "0000",
"license": {},
"settings": {
"ldap_encrypted_secrets_enabled": false,
"operating_system": "mac_os_x-11.2.2"
},
...
```