Add KMS UI (#2377)
Adds components to interact with KMS server connected to minio
This commit is contained in:
@@ -20,6 +20,7 @@ package restapi
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"sort"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/minio/console/models"
|
||||
@@ -120,7 +121,7 @@ func kmsMetrics(ctx context.Context, minioClient MinioAdmin) (*models.KmsMetrics
|
||||
RequestActive: &metrics.RequestActive,
|
||||
AuditEvents: &metrics.AuditEvents,
|
||||
ErrorEvents: &metrics.ErrorEvents,
|
||||
LatencyHistogram: nil,
|
||||
LatencyHistogram: parseHistogram(metrics.LatencyHistogram),
|
||||
Uptime: &metrics.UpTime,
|
||||
Cpus: &metrics.CPUs,
|
||||
UsableCPUs: &metrics.UsableCPUs,
|
||||
@@ -131,6 +132,17 @@ func kmsMetrics(ctx context.Context, minioClient MinioAdmin) (*models.KmsMetrics
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseHistogram(histogram map[int64]int64) (records []*models.KmsLatencyHistogram) {
|
||||
for duration, total := range histogram {
|
||||
records = append(records, &models.KmsLatencyHistogram{Duration: duration, Total: total})
|
||||
}
|
||||
cp := func(i, j int) bool {
|
||||
return records[i].Duration < records[j].Duration
|
||||
}
|
||||
sort.Slice(records, cp)
|
||||
return records
|
||||
}
|
||||
|
||||
func GetKMSAPIsResponse(session *models.Principal, params kmsAPI.KMSAPIsParams) (*models.KmsAPIsResponse, *models.Error) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
|
||||
@@ -6249,6 +6249,9 @@ func init() {
|
||||
"properties": {
|
||||
"duration": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -6319,7 +6322,10 @@ func init() {
|
||||
"type": "integer"
|
||||
},
|
||||
"latencyHistogram": {
|
||||
"$ref": "#/definitions/kmsLatencyHistogram"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/kmsLatencyHistogram"
|
||||
}
|
||||
},
|
||||
"requestActive": {
|
||||
"type": "integer"
|
||||
@@ -14817,6 +14823,9 @@ func init() {
|
||||
"properties": {
|
||||
"duration": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -14887,7 +14896,10 @@ func init() {
|
||||
"type": "integer"
|
||||
},
|
||||
"latencyHistogram": {
|
||||
"$ref": "#/definitions/kmsLatencyHistogram"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/kmsLatencyHistogram"
|
||||
}
|
||||
},
|
||||
"requestActive": {
|
||||
"type": "integer"
|
||||
|
||||
Reference in New Issue
Block a user