docs(api): add alert thresholds endpoints to swagger documentation

Add OpenAPI documentation for the new alert threshold management
endpoints used in traffic spike detection:

- GET /admin/alerts/thresholds - retrieve current threshold config
- PUT /admin/alerts/thresholds - update threshold configuration

Include AlertThresholdView and UpdateAlertThresholdsRequest schema
definitions with properties for QPS, RPM, TPM, RPD, TPD limits.
This commit is contained in:
zenfun
2025-12-31 15:57:27 +08:00
parent ba54abd424
commit 0b9556ee7e
3 changed files with 356 additions and 0 deletions

View File

@@ -187,6 +187,86 @@ const docTemplate = `{
}
}
},
"/admin/alerts/thresholds": {
"get": {
"security": [
{
"AdminAuth": []
}
],
"description": "Get current alert threshold configuration for traffic spike detection",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Get alert thresholds",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_api.AlertThresholdView"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
},
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Update alert threshold configuration for traffic spike detection",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update alert thresholds",
"parameters": [
{
"description": "Threshold configuration",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.UpdateAlertThresholdsRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_api.AlertThresholdView"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/alerts/{id}": {
"get": {
"security": [
@@ -4829,6 +4909,35 @@ const docTemplate = `{
}
}
},
"internal_api.AlertThresholdView": {
"type": "object",
"properties": {
"global_qps": {
"type": "integer"
},
"master_rpd": {
"type": "integer"
},
"master_rpm": {
"type": "integer"
},
"master_tpd": {
"type": "integer"
},
"master_tpm": {
"type": "integer"
},
"min_rpm_requests_1m": {
"type": "integer"
},
"min_tpm_tokens_1m": {
"type": "integer"
},
"updated_at": {
"type": "integer"
}
}
},
"internal_api.AlertView": {
"type": "object",
"properties": {
@@ -5745,6 +5854,32 @@ const docTemplate = `{
}
}
},
"internal_api.UpdateAlertThresholdsRequest": {
"type": "object",
"properties": {
"global_qps": {
"type": "integer"
},
"master_rpd": {
"type": "integer"
},
"master_rpm": {
"type": "integer"
},
"master_tpd": {
"type": "integer"
},
"master_tpm": {
"type": "integer"
},
"min_rpm_requests_1m": {
"type": "integer"
},
"min_tpm_tokens_1m": {
"type": "integer"
}
}
},
"internal_api.UpdateMasterRequest": {
"type": "object",
"properties": {

View File

@@ -181,6 +181,86 @@
}
}
},
"/admin/alerts/thresholds": {
"get": {
"security": [
{
"AdminAuth": []
}
],
"description": "Get current alert threshold configuration for traffic spike detection",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Get alert thresholds",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_api.AlertThresholdView"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
},
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Update alert threshold configuration for traffic spike detection",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update alert thresholds",
"parameters": [
{
"description": "Threshold configuration",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.UpdateAlertThresholdsRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_api.AlertThresholdView"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/alerts/{id}": {
"get": {
"security": [
@@ -4823,6 +4903,35 @@
}
}
},
"internal_api.AlertThresholdView": {
"type": "object",
"properties": {
"global_qps": {
"type": "integer"
},
"master_rpd": {
"type": "integer"
},
"master_rpm": {
"type": "integer"
},
"master_tpd": {
"type": "integer"
},
"master_tpm": {
"type": "integer"
},
"min_rpm_requests_1m": {
"type": "integer"
},
"min_tpm_tokens_1m": {
"type": "integer"
},
"updated_at": {
"type": "integer"
}
}
},
"internal_api.AlertView": {
"type": "object",
"properties": {
@@ -5739,6 +5848,32 @@
}
}
},
"internal_api.UpdateAlertThresholdsRequest": {
"type": "object",
"properties": {
"global_qps": {
"type": "integer"
},
"master_rpd": {
"type": "integer"
},
"master_rpm": {
"type": "integer"
},
"master_tpd": {
"type": "integer"
},
"master_tpm": {
"type": "integer"
},
"min_rpm_requests_1m": {
"type": "integer"
},
"min_tpm_tokens_1m": {
"type": "integer"
}
}
},
"internal_api.UpdateMasterRequest": {
"type": "object",
"properties": {

View File

@@ -443,6 +443,25 @@ definitions:
warning:
type: integer
type: object
internal_api.AlertThresholdView:
properties:
global_qps:
type: integer
master_rpd:
type: integer
master_rpm:
type: integer
master_tpd:
type: integer
master_tpm:
type: integer
min_rpm_requests_1m:
type: integer
min_tpm_tokens_1m:
type: integer
updated_at:
type: integer
type: object
internal_api.AlertView:
properties:
acked_at:
@@ -1045,6 +1064,23 @@ definitions:
propagate_to_keys:
type: boolean
type: object
internal_api.UpdateAlertThresholdsRequest:
properties:
global_qps:
type: integer
master_rpd:
type: integer
master_rpm:
type: integer
master_tpd:
type: integer
master_tpm:
type: integer
min_rpm_requests_1m:
type: integer
min_tpm_tokens_1m:
type: integer
type: object
internal_api.UpdateMasterRequest:
properties:
global_qps:
@@ -1517,6 +1553,56 @@ paths:
summary: Alert statistics
tags:
- admin
/admin/alerts/thresholds:
get:
description: Get current alert threshold configuration for traffic spike detection
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/internal_api.AlertThresholdView'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Get alert thresholds
tags:
- admin
put:
consumes:
- application/json
description: Update alert threshold configuration for traffic spike detection
parameters:
- description: Threshold configuration
in: body
name: request
required: true
schema:
$ref: '#/definitions/internal_api.UpdateAlertThresholdsRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/internal_api.AlertThresholdView'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Update alert thresholds
tags:
- admin
/admin/api-keys:
get:
description: List API keys with optional filters