Prometheus: Fix interpolating minStep for range queries when incremental querying enabled (#107715)

* return calculatedMinStep in first frame of the response

* update test files

* make the custom metadata as type of map[string]any

* append calculatedMinStep to custom metadata

* fix exemplar frame checking
This commit is contained in:
ismail simsek
2025-07-15 08:37:43 +02:00
committed by GitHub
parent 868791d751
commit 67573d5513
10 changed files with 41 additions and 5 deletions
+2 -2
View File
@@ -1140,8 +1140,8 @@ streamField:
return parsedLabelsMap, structuredMetadataMap, nil
}
func resultTypeToCustomMeta(resultType string) map[string]string {
return map[string]string{"resultType": resultType}
func resultTypeToCustomMeta(resultType string) map[string]any {
return map[string]any{"resultType": resultType}
}
func timeFromFloat(fv float64) time.Time {
+1 -1
View File
@@ -20,7 +20,7 @@ func ResultTypeFromFrame(frame *data.Frame) ResultType {
if frame.Meta.Custom == nil {
return ResultTypeUnknown
}
custom, ok := frame.Meta.Custom.(map[string]string)
custom, ok := frame.Meta.Custom.(map[string]any)
if !ok {
return ResultTypeUnknown
}
+8
View File
@@ -54,6 +54,14 @@ func (s *QueryData) parseResponse(ctx context.Context, q *models.Query, res *htt
addMetadataToMultiFrame(q, frame)
if i == 0 {
frame.Meta.ExecutedQueryString = executedQueryString(q)
if frame.Meta.Custom == nil {
frame.Meta.Custom = make(map[string]any)
}
if custom, ok := frame.Meta.Custom.(map[string]any); ok {
// This is required for incremental querying feature
// Knowing the calculated minStep is required for merging and caching the frames on frontend side
custom["calculatedMinStep"] = q.Step.Milliseconds()
}
}
}
+2
View File
@@ -7,6 +7,7 @@
// 1
// ],
// "custom": {
// "calculatedMinStep": 1000,
// "resultType": "matrix"
// },
// "executedQueryString": "Expr: histogram_quantile(0.95, sum(rate(tns_request_duration_seconds_bucket[4s])) by (le))\nStep: 1s"
@@ -44,6 +45,7 @@
1
],
"custom": {
"calculatedMinStep": 1000,
"resultType": "matrix"
},
"executedQueryString": "Expr: histogram_quantile(0.95, sum(rate(tns_request_duration_seconds_bucket[4s])) by (le))\nStep: 1s"
@@ -7,6 +7,7 @@
// 1
// ],
// "custom": {
// "calculatedMinStep": 1000,
// "resultType": "matrix"
// },
// "executedQueryString": "Expr: 1 / 0\nStep: 1s"
@@ -37,6 +38,7 @@
1
],
"custom": {
"calculatedMinStep": 1000,
"resultType": "matrix"
},
"executedQueryString": "Expr: 1 / 0\nStep: 1s"
@@ -7,6 +7,7 @@
// 1
// ],
// "custom": {
// "calculatedMinStep": 1000,
// "resultType": "matrix"
// },
// "executedQueryString": "Expr: test1\nStep: 1s"
@@ -37,6 +38,7 @@
1
],
"custom": {
"calculatedMinStep": 1000,
"resultType": "matrix"
},
"executedQueryString": "Expr: test1\nStep: 1s"
+2
View File
@@ -7,6 +7,7 @@
// 1
// ],
// "custom": {
// "calculatedMinStep": 1000,
// "resultType": "matrix"
// },
// "executedQueryString": "Expr: \nStep: 1s"
@@ -37,6 +38,7 @@
1
],
"custom": {
"calculatedMinStep": 1000,
"resultType": "matrix"
},
"executedQueryString": "Expr: \nStep: 1s"
+2
View File
@@ -7,6 +7,7 @@
// 1
// ],
// "custom": {
// "calculatedMinStep": 1000,
// "resultType": "matrix"
// },
// "executedQueryString": "Expr: \nStep: 1s"
@@ -60,6 +61,7 @@
1
],
"custom": {
"calculatedMinStep": 1000,
"resultType": "matrix"
},
"executedQueryString": "Expr: \nStep: 1s"