Skip to content

Commit 265c2ef

Browse files
authored
fix: correct real-time QPS calculation at the index level (#172)
* fix: correct real-time QPS calculation at the index level in agentless mode * chore: update release notes
1 parent 92008a2 commit 265c2ef

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

docs/content.en/docs/release-notes/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Information about release notes of INFINI Console is provided here.
1111
### Breaking changes
1212
### Features
1313
### Bug fix
14+
- Fixed incorrect real-time QPS calculation at the index level in agentless mode (#172)
1415
### Improvements
1516

1617
## 1.29.0 (2025-02-27)

docs/content.zh/docs/release-notes/_index.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ title: "版本历史"
1111
### Breaking changes
1212
### Features
1313
### Bug fix
14+
- 修复 agentless 模式下计算索引级别实时 qps 不准确的问题 (#172)
1415
### Improvements
1516

1617
## 1.29.0 (2025-02-27)

modules/elastic/api/cluster_overview.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"errors"
2929
"fmt"
3030
cerr "infini.sh/console/core/errors"
31+
v1 "infini.sh/console/modules/elastic/api/v1"
3132
"infini.sh/framework/modules/elastic/adapter"
3233
"net/http"
3334
"strings"
@@ -727,7 +728,12 @@ func (h *APIHandler) GetRealtimeClusterNodes(w http.ResponseWriter, req *http.Re
727728
shardCounts[shardInfo.NodeName] = 1
728729
}
729730
}
730-
qps, err := h.getNodeQPS(id, 20)
731+
minBucketSize, err := v1.GetMetricMinBucketSize(id, v1.MetricTypeNodeStats)
732+
if err != nil {
733+
h.WriteJSON(w, err.Error(), http.StatusInternalServerError)
734+
return
735+
}
736+
qps, err := h.getNodeQPS(id, minBucketSize)
731737
if err != nil {
732738
h.WriteJSON(w, util.MapStr{
733739
"error": err.Error(),
@@ -1176,7 +1182,7 @@ func (h *APIHandler) getNodeQPS(clusterID string, bucketSizeInSeconds int) (map[
11761182
{
11771183
"range": util.MapStr{
11781184
"timestamp": util.MapStr{
1179-
"gte": "now-1m",
1185+
"gte": fmt.Sprintf("now-1%ds", bucketSizeInSeconds),
11801186
"lte": "now",
11811187
},
11821188
},
@@ -1414,6 +1420,7 @@ func (h *APIHandler) getClusterMonitorState(w http.ResponseWriter, req *http.Req
14141420
}
14151421

14161422
}
1423+
ret["request"] = string(dsl)
14171424
h.WriteJSON(w, ret, http.StatusOK)
14181425
}
14191426

modules/elastic/api/v1/cluster_overview.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,13 @@ func (h *APIHandler) GetRealtimeClusterIndices(w http.ResponseWriter, req *http.
631631
indexInfos = &filterIndices
632632
}
633633

634-
qps, err := h.getIndexQPS(id, 20)
634+
minBucketSize, err := GetMetricMinBucketSize(id, MetricTypeIndexStats)
635+
if err != nil {
636+
resBody["error"] = err.Error()
637+
h.WriteJSON(w, resBody, http.StatusInternalServerError)
638+
return
639+
}
640+
qps, err := h.getIndexQPS(id, minBucketSize)
635641
if err != nil {
636642
resBody["error"] = err.Error()
637643
h.WriteJSON(w, resBody, http.StatusInternalServerError)
@@ -685,7 +691,7 @@ func (h *APIHandler) getIndexQPS(clusterID string, bucketSizeInSeconds int) (map
685691
"date": util.MapStr{
686692
"date_histogram": util.MapStr{
687693
"field": "timestamp",
688-
intervalField: "10s",
694+
intervalField: bucketSizeStr,
689695
},
690696
"aggs": util.MapStr{
691697
"index_total": util.MapStr{
@@ -729,7 +735,7 @@ func (h *APIHandler) getIndexQPS(clusterID string, bucketSizeInSeconds int) (map
729735
{
730736
"range": util.MapStr{
731737
"timestamp": util.MapStr{
732-
"gte": "now-1m",
738+
"gte": fmt.Sprintf("now-%ds", bucketSizeInSeconds*5),
733739
"lte": "now",
734740
},
735741
},

0 commit comments

Comments
 (0)