Skip to content

Conversation

harry671003
Copy link
Contributor

@harry671003 harry671003 commented May 15, 2024

Related Issues

Description

In #13396 a new limit param for the series, label names and label values APIs was introduced. This limit is currently only applied in the api.go. The storage implementations that do not support streaming such as Thanos, Cortex etc, will not be able to receive the limit param and would have to return all the results.

This change would pass the limit param as hints to storage so that the implementations can use that to return only the required number of results.

Copy link
Member

@machine424 machine424 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this.

AFAIU, the limit hint isn't taken into account by the mergeGenericQuerier implementation e.g.
For the Select it's not that important as it streams, but we'll need that for the labels fcts.
We could create an issue for that and address it in another PR.

@machine424
Copy link
Member

After this is in place, we could also make use of that limit hint for storage.remote.read-sample-limit https://github.com/prometheus/prometheus/pull/4532/files

@harry671003 harry671003 force-pushed the pass_limit_to_querier branch from 09dc94f to d3f5bae Compare May 21, 2024 17:19
@harry671003
Copy link
Contributor Author

After this is in place, we could also make use of that limit hint for storage.remote.read-sample-limit https://github.com/prometheus/prometheus/pull/4532/files

@machine424 - Sorry, I didn't understand how the sample limit is relevant here. Could you elaborate more?

@harry671003
Copy link
Contributor Author

Hey @bboreham, could you please take a look at this PR?

@machine424
Copy link
Member

machine424 commented May 23, 2024

After this is in place, we could also make use of that limit hint for storage.remote.read-sample-limit https://github.com/prometheus/prometheus/pull/4532/files

@machine424 - Sorry, I didn't understand how the sample limit is relevant here. Could you elaborate more?

We can, later, set the limit hint here

var hints *storage.SelectHints
if query.Hints != nil {
hints = &storage.SelectHints{
Start: query.Hints.StartMs,
End: query.Hints.EndMs,
Step: query.Hints.StepMs,
Func: query.Hints.Func,
Grouping: query.Hints.Grouping,
Range: query.Hints.RangeMs,
By: query.Hints.By,
}
}
var ws annotations.Annotations
resp.Results[i], ws, err = ToQueryResult(querier.Select(ctx, false, hints, filteredMatchers...), h.remoteReadSampleLimit)
in accordance with h.remoteReadSampleLimit if it makes sense.


You can rebase as #14116 was merged.

@harry671003 harry671003 force-pushed the pass_limit_to_querier branch from d3f5bae to 1edec91 Compare May 23, 2024 17:33
@harry671003 harry671003 requested a review from machine424 May 23, 2024 17:34
Copy link
Member

@bboreham bboreham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I read this correctly you didn't implement early exit when the limit was hit; just added the interface so that someone else could do that.
This seems wrong to me; if we're going to add this complexity we should make Prometheus better too.

@harry671003
Copy link
Contributor Author

harry671003 commented May 27, 2024

If I read this correctly you didn't implement early exit when the limit was hit; just added the interface so that someone else could do that. This seems wrong to me; if we're going to add this complexity we should make Prometheus better too.

I was afraid that including this change in this PR would make it big. I will create another PR soon after this to implement those changes.

@harry671003 harry671003 force-pushed the pass_limit_to_querier branch 2 times, most recently from 9b7dd3e to 0057a07 Compare May 27, 2024 19:01
@machine424
Copy link
Member

If I read this correctly you didn't implement early exit when the limit was hit; just added the interface so that someone else could do that. This seems wrong to me; if we're going to add this complexity we should make Prometheus better too.

Yes, we discussed that for mergeGenericQuerier here #14109 (review), the labels related ones would be more needed as that implementation's Select is an iteration. Did we miss any other implementation?
(If we agree on that, let's mention that in the PR description, open en issue and link it there as well)

Copy link
Member

@machine424 machine424 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm so far, just some nits.

@harry671003 harry671003 force-pushed the pass_limit_to_querier branch from 0057a07 to 00e966a Compare June 5, 2024 17:58
@harry671003 harry671003 force-pushed the pass_limit_to_querier branch from 00e966a to 403214b Compare June 6, 2024 16:20
machine424
machine424 previously approved these changes Jun 6, 2024
Copy link
Member

@machine424 machine424 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks again!
looking forward to the implementation PR.
Let's see if it's ok for Bryan as well.

@harry671003 harry671003 force-pushed the pass_limit_to_querier branch 3 times, most recently from 9b9d037 to edc8d0e Compare June 9, 2024 21:20
@harry671003 harry671003 force-pushed the pass_limit_to_querier branch from edc8d0e to 4ca2212 Compare June 9, 2024 21:26
@harry671003
Copy link
Contributor Author

I took a stab at implementing the limits inside merge.go
I included those changes in the same PR as changes seemed minimal.
Could you take another look @machine424 and @bboreham ?

@machine424
Copy link
Member

I took a stab at implementing the limits inside merge.go I included those changes in the same PR as changes seemed minimal. Could you take another look @machine424 and @bboreham ?

I'd proceed as we agreed: merge the PR with the interface changes only (I already approved those) if no one has an objection, and then add the implementation in another PR. This will also keep reviewing easy.

@harry671003 harry671003 force-pushed the pass_limit_to_querier branch from 14b8811 to 4a46dcf Compare June 19, 2024 17:03
@harry671003
Copy link
Contributor Author

I'd proceed as we agreed: merge the PR with the interface changes only (I already approved those) if no one has an objection, and then add the implementation in another PR.

I reverted back to the original. I can create a separate PR for the implementation. :)

@harry671003 harry671003 requested a review from machine424 June 19, 2024 17:08
Signed-off-by: 🌲 Harry 🌊 John 🏔 <johrry@amazon.com>
@harry671003 harry671003 force-pushed the pass_limit_to_querier branch from 4a46dcf to d5f6887 Compare June 20, 2024 16:47
@harry671003 harry671003 requested a review from bboreham June 21, 2024 14:43
machine424
machine424 previously approved these changes Jun 24, 2024
Copy link
Member

@machine424 machine424 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, Let's see if it's ok for Bryan.

@harry671003
Copy link
Contributor Author

Could this PR be merged if there are no objections?

@harry671003 harry671003 requested a review from machine424 July 8, 2024 17:59
Copy link
Member

@bboreham bboreham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants