Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 4c22f98

Browse files
authored
Merge pull request #957 from grafana/fix-points-return-measurement-mdp
fix pointsReturn to consider MaxDataPoints based consolidation
2 parents ee8e277 + 291f6e2 commit 4c22f98

15 files changed

+23
-44
lines changed

api/models/cluster_gen.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/models/cluster_gen_test.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/models/graphite_gen.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/models/graphite_gen_test.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/models/series_gen.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/models/series_gen_test.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/query_engine.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/grafana/metrictank/api/models"
77
"github.com/grafana/metrictank/api/response"
8+
"github.com/grafana/metrictank/consolidation"
89
"github.com/grafana/metrictank/mdata"
910
"github.com/grafana/metrictank/stats"
1011
"github.com/grafana/metrictank/util"
@@ -24,7 +25,7 @@ var (
2425
)
2526

2627
// alignRequests updates the requests with all details for fetching, making sure all metrics are in the same, optimal interval
27-
// note: it is assumed that all requests have the same from & to.
28+
// note: it is assumed that all requests have the same maxDataPoints, from & to.
2829
// also takes a "now" value which we compare the TTL against
2930
func alignRequests(now, from, to uint32, reqs []models.Req) ([]models.Req, uint32, uint32, error) {
3031
tsRange := to - from
@@ -143,7 +144,13 @@ func alignRequests(now, from, to uint32, reqs []models.Req) ([]models.Req, uint3
143144
reqRenderChosenArchive.Value(req.Archive)
144145
}
145146

146-
pointsReturn := uint32(len(reqs)) * (tsRange / interval)
147+
pointsPerSerie := tsRange / interval
148+
if reqs[0].MaxPoints > 0 && pointsPerSerie > reqs[0].MaxPoints {
149+
aggNum := consolidation.AggEvery(pointsPerSerie, reqs[0].MaxPoints)
150+
pointsPerSerie = pointsPerSerie / aggNum
151+
}
152+
153+
pointsReturn := uint32(len(reqs)) * pointsPerSerie
147154
reqRenderPointsFetched.ValueUint32(pointsFetch)
148155
reqRenderPointsReturned.ValueUint32(pointsReturn)
149156

consolidation/consolidation_gen.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

consolidation/consolidation_gen_test.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

idx/idx_gen.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

idx/idx_gen_test.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdata/chunk/archive/archive_gen.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdata/chunk/archive/archive_gen_test.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdata/chunk/itergen_gen.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdata/chunk/itergen_gen_test.go

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)