Add endpoint for retrieving Service Ping Ping payload
What does this MR do and why?
This MR adds new API endpoint which exposes the latest ServicePing payload.
If no payload was generated on the instance, it returns an empty body
In order to access payload user needs a PAT with service_ping_access
scope, which was added in !140936 (merged)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Endpoint OpenAPI specs:
"/api/v4/usage_data/service_ping":
get:
summary: Get the latest ServicePing payload
description: This feature was introduces in Gitlab 16.8
produces:
- application/json
responses:
'200':
description: Get the latest ServicePing payload
'401':
description: 401 Unauthorized
'403':
description: Forbidden
'404':
description: Not found
tags:
- usage_data
operationId: getApiV4UsageDataServicePing
How to set up and validate locally
- Generate SerivicePing payload
Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)
in rails console. Alternatively you can try to retrieve an empty payload to verify it works. - Create PAT with
service_ping_access
scope (available only for admins) - Verify Service ping can be downloaded via API call
curl -X GET --location "http://localhost:3000/api/v4/usage_data/service_ping?private_token=abc" \
-H "Accept: application/json"
Related to #435351 (closed)
Edited by Niko Belokolodov