From a52c104562b8c0988e28544949db5c6b71327d17 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Tue, 6 Jun 2023 17:25:53 +0530 Subject: [PATCH] fix: remove the top 10 limit on key operations table (#2824) Co-authored-by: Vishal Sharma --- pkg/query-service/app/clickhouseReader/reader.go | 8 ++++++-- pkg/query-service/model/queryParams.go | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go index 30d551e4b8..b12d3bbd9e 100644 --- a/pkg/query-service/app/clickhouseReader/reader.go +++ b/pkg/query-service/app/clickhouseReader/reader.go @@ -1870,14 +1870,18 @@ func (r *ClickHouseReader) GetTopOperations(ctx context.Context, queryParams *mo if errStatus != nil { return nil, errStatus } - query += " GROUP BY name ORDER BY p99 DESC LIMIT 10" + query += " GROUP BY name ORDER BY p99 DESC" + if queryParams.Limit > 0 { + query += " LIMIT @limit" + args = append(args, clickhouse.Named("limit", queryParams.Limit)) + } err := r.db.Select(ctx, &topOperationsItems, query, args...) zap.S().Debug(query) if err != nil { zap.S().Error("Error in processing sql query: ", err) - return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("Error in processing sql query")} + return nil, &model.ApiError{Typ: model.ErrorExec, Err: fmt.Errorf("error in processing sql query")} } if topOperationsItems == nil { diff --git a/pkg/query-service/model/queryParams.go b/pkg/query-service/model/queryParams.go index a94f57ad02..429471616f 100644 --- a/pkg/query-service/model/queryParams.go +++ b/pkg/query-service/model/queryParams.go @@ -160,6 +160,7 @@ type GetTopOperationsParams struct { Start *time.Time End *time.Time Tags []TagQueryParam `json:"tags"` + Limit int `json:"limit"` } type GetUsageParams struct {