Skip to content
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

query: fix querying with interleaved data #5035

Merged
merged 2 commits into from
Jan 10, 2022

Conversation

GiedriusS
Copy link
Member

@GiedriusS GiedriusS commented Jan 6, 2022

Fix querying when some data has been pushed down and some - hasn't.
Since max_over_time and min_over_time remove __name__ from the
results either way, let's do that inside Select() to have a unified form
of data.

Add test to cover this case.

Without this code, the test fails:

level=error ts=2022-01-06T16:28:37.959956685Z msg="function failed. Retrying in next tick" err="read query instant response: expected 2xx response, got 422. Body: {\"status\":\"error\",\"errorType\":\"execution\",\"error\":\"vector cannot contain metrics with the same labelset\"}\n"

Closes #5033.

@GiedriusS
Copy link
Member Author

cc @fpetkovski

Fix querying when some data has been pushed down and some - hasn't.
Since `max_over_time` and `min_over_time` remove `__name__` from the
results either way, let's do that inside Select() to have a unified form
of data.

Add test to cover this case.

Without this code, the test fails:

```
level=error ts=2022-01-06T16:28:37.959956685Z msg="function failed. Retrying in next tick" err="read query instant response: expected 2xx response, got 422. Body: {\"status\":\"error\",\"errorType\":\"execution\",\"error\":\"vector cannot contain metrics with the same labelset\"}\n"
```

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
@GiedriusS GiedriusS force-pushed the attach_metrics_name branch from 62bef32 to fac4e88 Compare January 6, 2022 16:41
fpetkovski
fpetkovski previously approved these changes Jan 7, 2022
testutil.Ok(t, err)
t.Cleanup(e2ethanos.CleanScenario(t, e))

prom1, sidecar1, err := e2ethanos.NewPrometheusWithSidecar(e, "p1", defaultPromConfig("p1", 0, "", ""), "", e2ethanos.DefaultPrometheusImage(), "remote-write-receiver")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intended to enable remote write receiver?

Copy link
Contributor

Choose a reason for hiding this comment

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

The test synthesizes samples by remote writing them, which is why the receiver feature is needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @fpetkovski. I thought it was using data from the block only. Didn't notice the remote write part.

test/e2e/query_test.go Show resolved Hide resolved
Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

LGTM

// Delete the metric's name from the result because that's what the
// PromQL does either way and we want our iterator to work with data
// that was either pushed down or not.
if q.enableQueryPushdown && (hints.Func == "max_over_time" || hints.Func == "min_over_time") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious why promql does this. Isn't it a bug?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, it is a feature. Think of these functions like they are calculating the maximum over all input, not just for each unique labelset. I think this is where it happens: https://github.com/prometheus/prometheus/blob/d677aa4b29a8a0cf9f61af04bbf5bfdce893cf23/promql/engine.go#L1304-L1310.

Copy link
Member Author

Choose a reason for hiding this comment

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

Once more functions are being pushed down, we will need to improve the logic here. Probably we will need to refactor this into a separate struct? I don't know yet

@GiedriusS GiedriusS merged commit 9a8c984 into thanos-io:main Jan 10, 2022
@GiedriusS GiedriusS deleted the attach_metrics_name branch January 10, 2022 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pushdown: fix querying when proxied metrics have a mixture of pushed down and not pushed down data
3 participants