Service Ping API
- Tier: 基础版,专业版,旗舰版
- Offering: 私有化部署
使用此 API 与极狐GitLab Service Ping 过程进行交互。有关更多信息,请参阅 Service Ping 开发指南。
导出 Service Ping 数据
History
- 在极狐GitLab 16.9 中引入。
需要具有 read_service_ping 范围的个人访问令牌。
返回在 Service Ping 中收集的 JSON 负载。如果应用缓存中没有可用的负载数据,则返回空响应。如果负载数据为空,请确保启用 Service Ping 功能并等待 cron 作业执行,或手动生成负载数据。
示例请求:
shellcurl --request GET \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/usage_data/service_ping"
示例响应:
json1 "recorded_at": "2024-01-15T23:33:50.387Z", 2 "license": {}, 3 "counts": { 4 "assignee_lists": 0, 5 "ci_builds": 463, 6 "ci_external_pipelines": 0, 7 "ci_pipeline_config_auto_devops": 0, 8 "ci_pipeline_config_repository": 0, 9 "ci_triggers": 0, 10 "ci_pipeline_schedules": 0 11...
解读 schema_inconsistencies_metric
Service Ping JSON 负载包含 schema_inconsistencies_metric。数据库模式不一致是预期的,并不太可能表明您的实例有问题。
此指标仅用于排查正在进行的问题,不应用作常规健康检查。该指标应仅在极狐GitLab 支持的指导下进行解读。该指标报告与数据库模式检查器 Rake 任务相同的数据库模式不一致。
将指标定义导出为单个 YAML 文件
将所有指标定义导出为单个 YAML 文件,类似于指标字典,以便于导入。
plaintextGET /usage_data/metric_definitions
示例请求:
shellcurl --request GET \ --url "https://gitlab.example.com/api/v4/usage_data/metric_definitions"
示例响应:
yaml1--- 2- key_path: redis_hll_counters.search.i_search_paid_monthly 3 description: Calculated unique users to perform a search with a paid license enabled 4 by month 5 product_group: global_search 6 value_type: number 7 status: active 8 time_frame: 28d 9 data_source: redis_hll 10 tier: 11 - 专业版 12 - 旗舰版 13...
导出 Service Ping SQL 查询
此操作位于 usage_data_queries_api 功能标志后面,仅适用于极狐GitLab 实例管理员用户。
History
- 在极狐GitLab 13.11 中引入。
- 部署在名为 usage_data_queries_api 的功能标志后,默认禁用。
返回用于计算 Service Ping 的所有原始 SQL 查询。
plaintextGET /usage_data/queries
示例请求:
shellcurl --request GET \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/usage_data/queries"
示例响应:
json1{ 2 "recorded_at": "2021-03-23T06:31:21.267Z", 3 "uuid": null, 4 "hostname": "localhost", 5 "version": "13.11.0-pre", 6 "installation_type": "gitlab-development-kit", 7 "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))", 8 "edition": "EE", 9 "license_md5": "c701acc03844c45366dd175ef7a4e19c", 10 "license_sha256": "366dd175ef7a4e19cc701acc03844c45366dd175ef7a4e19cc701acc03844c45", 11 "license_id": null, 12 "historical_max_users": 0, 13 "licensee": { 14 "Name": "John Doe1" 15 }, 16 "license_user_count": null, 17 "license_starts_at": "1970-01-01", 18 "license_expires_at": "2022-02-23", 19 "license_plan": "starter", 20 "license_add_ons": { 21 "GitLab_FileLocks": 1, 22 "GitLab_Auditor_User": 1 23 }, 24 "license_trial": null, 25 "license_subscription_id": "0000", 26 "license": {}, 27 "settings": { 28 "ldap_encrypted_secrets_enabled": false, 29 "operating_system": "mac_os_x-11.2.2" 30 }, 31 "counts": { 32 "assignee_lists": "SELECT COUNT(\"lists\".\"id\") FROM \"lists\" WHERE \"lists\".\"list_type\" = 3", 33 "boards": "SELECT COUNT(\"boards\".\"id\") FROM \"boards\"", 34 "ci_builds": "SELECT COUNT(\"ci_builds\".\"id\") FROM \"ci_builds\" WHERE \"ci_builds\".\"type\" = 'Ci::Build'", 35 "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)", 36 "ci_external_pipelines": "SELECT COUNT(\"ci_pipelines\".\"id\") FROM \"ci_pipelines\" WHERE \"ci_pipelines\".\"source\" = 6", 37 "ci_pipeline_config_auto_devops": "SELECT COUNT(\"ci_pipelines\".\"id\") FROM \"ci_pipelines\" WHERE \"ci_pipelines\".\"config_source\" = 2", 38 "ci_pipeline_config_repository": "SELECT COUNT(\"ci_pipelines\".\"id\") FROM \"ci_pipelines\" WHERE \"ci_pipelines\".\"config_source\" = 1", 39 "ci_runners": "SELECT COUNT(\"ci_runners\".\"id\") FROM \"ci_runners\"", 40...
UsageDataNonSqlMetrics API
此操作位于 usage_data_non_sql_metrics 功能标志后面,仅适用于极狐GitLab 实例管理员用户。
History
- 在极狐GitLab 13.11 中引入。
- 部署在名为 usage_data_non_sql_metrics 的功能标志后,默认禁用。
返回 Service Ping 中使用的所有非 SQL 指标数据。
示例请求:
shellcurl --request GET \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/usage_data/non_sql_metrics"
示例响应:
json1{ 2 "recorded_at": "2021-03-26T07:04:03.724Z", 3 "uuid": null, 4 "hostname": "localhost", 5 "version": "13.11.0-pre", 6 "installation_type": "gitlab-development-kit", 7 "active_user_count": -3, 8 "edition": "EE", 9 "license_md5": "bb8cd0d8a6d9569ff3f70b8927a1f949", 10 "license_sha256": "366dd175ef7a4e19cc701acc03844c45366dd175ef7a4e19cc701acc03844c45", 11 "license_id": null, 12 "historical_max_users": 0, 13 "licensee": { 14 "Name": "John Doe1" 15 }, 16 "license_user_count": null, 17 "license_starts_at": "1970-01-01", 18 "license_expires_at": "2022-02-26", 19 "license_plan": "starter", 20 "license_add_ons": { 21 "GitLab_FileLocks": 1, 22 "GitLab_Auditor_User": 1 23 }, 24 "license_trial": null, 25 "license_subscription_id": "0000", 26 "license": {}, 27 "settings": { 28 "ldap_encrypted_secrets_enabled": false, 29 "operating_system": "mac_os_x-11.2.2" 30 }, 31...
事件跟踪 API
跟踪极狐GitLab 中的内部事件。需要具有 api 或 ai_workflows 范围的个人访问令牌。
要跟踪到 Snowplow 的事件,请将 send_to_snowplow 参数设置为 true。
示例请求:
shell1curl --header "PRIVATE-TOKEN: <your_access_token>" \ 2 --header "Content-Type: application/json" \ 3 --request POST \ 4 --data '{ 5 "event": "mr_name_changed", 6 "send_to_snowplow": true, 7 "namespace_id": 1, 8 "project_id": 1, 9 "additional_properties": { 10 "lang": "eng" 11 } 12 }' \ 13 --url "https://gitlab.example.com/api/v4/usage_data/track_event"
如果需要跟踪多个事件,请将事件数组发送到 /track_events 端点:
shell1curl --header "PRIVATE-TOKEN: <your_access_token>" \ 2 --header "Content-Type: application/json" \ 3 --request POST \ 4 --data '{ 5 "events": [ 6 { 7 "event": "mr_name_changed", 8 "namespace_id": 1, 9 "project_id": 1, 10 "additional_properties": { 11 "lang": "eng" 12 } 13 }, 14 { 15 "event": "mr_name_changed", 16 "namespace_id": 2, 17 "project_id": 2, 18 "additional_properties": { 19 "lang": "eng" 20 } 21 } 22 ] 23 }' \ 24 --url "https://gitlab.example.com/api/v4/usage_data/track_events"