Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ etc
bin/
ui/
static/
.vscode/
.vscode/
jdk/
1 change: 1 addition & 0 deletions sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti
v1Router.POST("/configurations/git/test", v1.TestGitConnectionV1, sqleMiddleware.OpGlobalAllowed())

// statistic
v1Router.GET("/statistic/instances/resource_overview_statistics", v1.GetInstanceOverviewStatistics)
v1Router.GET("/statistic/instances/type_percent", v1.GetInstancesTypePercentV1, sqleMiddleware.ViewGlobalAllowed())
v1Router.GET("/statistic/instances/sql_average_execution_time", v1.GetSqlAverageExecutionTimeV1, sqleMiddleware.ViewGlobalAllowed())
v1Router.GET("/statistic/license/usage", v1.GetLicenseUsageV1, sqleMiddleware.ViewGlobalAllowed())
Expand Down
29 changes: 29 additions & 0 deletions sqle/api/controller/v1/statistic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,3 +1019,32 @@ func GetInstanceHealthV1(c echo.Context) error {
Data: dBTypeHealth,
})
}

type GetInstanceOverviewStatisticsReq struct {
FilterByDBServiceIds []string `query:"filter_by_db_service_ids" params:"filter_by_db_service_ids" json:"filter_by_db_service_ids"`
}

type GetInstanceOverviewStatisticsRes struct {
controller.BaseRes
Data []InstanceOverviewStatistics `json:"data"`
}

type InstanceOverviewStatistics struct {
InstanceID string `json:"instance_id"`
AvgScore float32 `json:"avg_score"`
HighPrioritySQLCount int32 `json:"high_priority_sql_count"`
PendingWorkflowCount int32 `json:"pending_workflow_count"`
}

// GetInstanceOverviewStatistics
// @Summary 获取实例概览统计信息
// @Description get instance overview statistics including average score, high priority SQL count and pending workflow count
// @Tags statistic
// @Id getInstanceOverviewStatisticsV1
// @Security ApiKeyAuth
// @Param filter_by_db_service_ids query []string false "filter by db service ids"
// @Success 200 {object} v1.GetInstanceOverviewStatisticsRes
// @router /v1/statistic/instances/resource_overview_statistics [get]
func GetInstanceOverviewStatistics(c echo.Context) error {
return getInstanceOverviewStatistics(c)
}
4 changes: 4 additions & 0 deletions sqle/api/controller/v1/statistic_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ func getSqlAverageExecutionTimeV1(c echo.Context) error {
func getSqlExecutionFailPercentV1(c echo.Context) error {
return controller.JSONBaseErrorReq(c, errCommunityEditionDoesNotSupportStatistic)
}

func getInstanceOverviewStatistics(c echo.Context) error {
return controller.JSONBaseErrorReq(c, errCommunityEditionDoesNotSupportStatistic)
}
70 changes: 70 additions & 0 deletions sqle/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9144,6 +9144,40 @@ var doc = `{
}
}
},
"/v1/statistic/instances/resource_overview_statistics": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get instance overview statistics including average score, high priority SQL count and pending workflow count",
"tags": [
"statistic"
],
"summary": "获取实例概览统计信息",
"operationId": "getInstanceOverviewStatisticsV1",
"parameters": [
{
"type": "array",
"items": {
"type": "string"
},
"description": "filter by db service ids",
"name": "filter_by_db_service_ids",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.GetInstanceOverviewStatisticsRes"
}
}
}
}
},
"/v1/statistic/instances/sql_average_execution_time": {
"get": {
"security": [
Expand Down Expand Up @@ -15250,6 +15284,25 @@ var doc = `{
}
}
},
"v1.GetInstanceOverviewStatisticsRes": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"example": 0
},
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.InstanceOverviewStatistics"
}
},
"message": {
"type": "string",
"example": "ok"
}
}
},
"v1.GetInstanceSchemaResV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -16991,6 +17044,23 @@ var doc = `{
}
}
},
"v1.InstanceOverviewStatistics": {
"type": "object",
"properties": {
"avg_score": {
"type": "number"
},
"high_priority_sql_count": {
"type": "integer"
},
"instance_id": {
"type": "string"
},
"pending_workflow_count": {
"type": "integer"
}
}
},
"v1.InstanceSchemaResV1": {
"type": "object",
"properties": {
Expand Down
70 changes: 70 additions & 0 deletions sqle/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9128,6 +9128,40 @@
}
}
},
"/v1/statistic/instances/resource_overview_statistics": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "get instance overview statistics including average score, high priority SQL count and pending workflow count",
"tags": [
"statistic"
],
"summary": "获取实例概览统计信息",
"operationId": "getInstanceOverviewStatisticsV1",
"parameters": [
{
"type": "array",
"items": {
"type": "string"
},
"description": "filter by db service ids",
"name": "filter_by_db_service_ids",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.GetInstanceOverviewStatisticsRes"
}
}
}
}
},
"/v1/statistic/instances/sql_average_execution_time": {
"get": {
"security": [
Expand Down Expand Up @@ -15234,6 +15268,25 @@
}
}
},
"v1.GetInstanceOverviewStatisticsRes": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"example": 0
},
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.InstanceOverviewStatistics"
}
},
"message": {
"type": "string",
"example": "ok"
}
}
},
"v1.GetInstanceSchemaResV1": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -16975,6 +17028,23 @@
}
}
},
"v1.InstanceOverviewStatistics": {
"type": "object",
"properties": {
"avg_score": {
"type": "number"
},
"high_priority_sql_count": {
"type": "integer"
},
"instance_id": {
"type": "string"
},
"pending_workflow_count": {
"type": "integer"
}
}
},
"v1.InstanceSchemaResV1": {
"type": "object",
"properties": {
Expand Down
46 changes: 46 additions & 0 deletions sqle/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,19 @@ definitions:
example: ok
type: string
type: object
v1.GetInstanceOverviewStatisticsRes:
properties:
code:
example: 0
type: integer
data:
items:
$ref: '#/definitions/v1.InstanceOverviewStatistics'
type: array
message:
example: ok
type: string
type: object
v1.GetInstanceSchemaResV1:
properties:
code:
Expand Down Expand Up @@ -3273,6 +3286,17 @@ definitions:
instance_name:
type: string
type: object
v1.InstanceOverviewStatistics:
properties:
avg_score:
type: number
high_priority_sql_count:
type: integer
instance_id:
type: string
pending_workflow_count:
type: integer
type: object
v1.InstanceSchemaResV1:
properties:
schema_name_list:
Expand Down Expand Up @@ -12748,6 +12772,28 @@ paths:
summary: 直接审核SQL
tags:
- sql_audit
/v1/statistic/instances/resource_overview_statistics:
get:
description: get instance overview statistics including average score, high
priority SQL count and pending workflow count
operationId: getInstanceOverviewStatisticsV1
parameters:
- description: filter by db service ids
in: query
items:
type: string
name: filter_by_db_service_ids
type: array
responses:
"200":
description: OK
schema:
$ref: '#/definitions/v1.GetInstanceOverviewStatisticsRes'
security:
- ApiKeyAuth: []
summary: 获取实例概览统计信息
tags:
- statistic
/v1/statistic/instances/sql_average_execution_time:
get:
description: get average execution time of sql
Expand Down
Loading