query:thanos-query adaptive downsample by max_source_resolution #4526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
here is a case: when user don't know how thanos downsample datas comes such as [raw,5m,1h]. And they may use a not suitable duration parameter [15s] like:
rate(foo[15s]& max_source_resolution=1h,
the result may be empty or only a little raw data of latest time. because the promql funcrate must need two datas accross duration time, max_source_resolution=1h, means there is only one data in 1h, the final result of rate will fail or loss data.
So , we add an adaptive method, it check the real duration time, and compared with max_source_resolution, if less than max_so.., the duration time will be changed to a suitable value.
Verification
in our systerm, we test it by set :
a: rate(foo[15s]&start1627913400&end=1628086200&step=600&max_source_resolution=1h,
b:rate(foo[15s]&start1627913400&end=1628086200&step=600&max_source_resolution=5m,
a->a1:rate(foo[2h]&start1627913400&end=1628086200&step=600&max_source_resolution=1h,
b->b1:rate(foo[10m]&start1627913400&end=1628086200&step=600&max_source_resolution=5m,
the result datas of a1 and b1 are in expectation than previous version of thanos-query.