-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote read adding external labels might lead to unsorted response #12605
Comments
Add test for bug prometheus#12605 for starters. Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
Add test for bug prometheus#12605 for starters. Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
Thanks! I think the bug is valid - Prometheus should detect and deal with cases of external labels being duplicated in the scraped labels. The answer "how to deal" is suggested by the honor label settings https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
Unfortunately, unless we ignore those series or stop attaching external labels, we break streaming efficiency. Even worse - we only know results will be unsorted after we streamed something already. Not sure yet what's the most explicit way out of this. Some ideas: A) Add unsorted series field to message stream and stream those series there. Callers could do k-way merge or so. |
Add test for bug prometheus#12605 for starters. Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
The problem is that external labels are not part of I have also checked that with federated Prometheus, Prometheus itself sorts the retrieved response thus hiding this problem. If in the future we want to have the same streaming approach in federated Prometheus, we will need to solve this somehow. Sending external labels separately from the TSDB series still doesn't allow to use of this interface in a streaming way because adding those labels later on to the retrieved series might lead to the same problem i.e. the set becomes unsorted and thus we need to buffer+resort. Just wanted to remind any other readers of this that we care about sortedness from /api/v1/read because in Thanos (and others?) essentially we want to know when we have received all copies of the same time series. Sorted output allows us to use k-way to merge everything together easily. Some hybrid approach might be feasible here -> if an unsorted response is detected then we could send some hint or something. But overall that feels like a hack. As far as I can tell, the only short-term solution is to buffer everything in /api/v1/read, even with the XOR format. And then later on we could think of a way to attach all external labels to the TSDB + mark that somehow so as to know whether that was enabled? Maybe something crazy like this could work:
? |
What did you do?
/api/v1/read
is supposed to always give a sorted series set as a response. Consider the following:External labels are
region: foo
.Series without any external labels:
prometheus/storage/remote/codec.go
Line 230 in 03e549c
region: foo
if it does not exist while iterating.What did you expect to see?
I expected to see an error? that the response cannot contain the same label set. Not sure, though.
What did you see instead? Under which circumstances?
The result is the following:
System information
No response
Prometheus version
No response
Prometheus configuration file
No response
Alertmanager version
No response
Alertmanager configuration file
No response
Logs
No response
The text was updated successfully, but these errors were encountered: