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

Fix label extraction pushdown on instant queries #6215

Merged
merged 2 commits into from
May 24, 2022

Conversation

ssncferreira
Copy link
Contributor

@ssncferreira ssncferreira commented May 20, 2022

What this PR does / why we need it:

In the context of instant queries with label extractors logfmt & json, when combining range vector aggregators bytes_over_time , count_over_time , rate and bytes_rate with vector aggregators max and min, it is not possible to use sum as aggregation operator for downstream queries results. This results from the recent change to push downstream vector aggregator expressions: #6132
List of failing tests: https://drone.grafana.net/grafana/loki/12011/2/5

This PR uses only concat as a downstream aggregation operator for expressions of the following types:

  • max(bytes_over_time(logfmt|json))
  • max(count_over_time(logfmt|json))
  • max(bytes_over_time(logfmt|json))
  • max(count_over_time(logfmt|json))

Note: since rate and bytes_rate range vector aggregator expressions are converted internally to a binary operation, these expressions return noop when inside a max or min vector aggregator with a label extraction operator.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated
  • Is this an important fix or new feature? Add an entry in the CHANGELOG.md.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

@ssncferreira ssncferreira requested a review from a team as a code owner May 20, 2022 23:58
@ssncferreira ssncferreira self-assigned this May 20, 2022
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0.1%
+               loki	0%

@ssncferreira ssncferreira force-pushed the fix_label_extraction_pushdown branch from 1304c16 to 8c8bc11 Compare May 21, 2022 00:03
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0.1%
+               loki	0%

Copy link
Contributor

@chaudum chaudum left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for catching this issue, great job!

Comment on lines +346 to +349
// Downstream queries with label extractors can potentially produce a huge amount of series
// which can impact the queries and consequently fail.
// Note: vector aggregation expressions aggregate the result in a single empty label set,
// so these expressions can be pushed downstream
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@vlad-diachenko vlad-diachenko left a comment

Choose a reason for hiding this comment

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

looks great ;)

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@cyriltovena cyriltovena merged commit 0dfd2cb into main May 24, 2022
@cyriltovena cyriltovena deleted the fix_label_extraction_pushdown branch May 24, 2022 12:43
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.

5 participants