-
Notifications
You must be signed in to change notification settings - Fork 634
mqe: Allow usage of Mimir Query Engine in query-frontend #11417
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
Conversation
16573ec
to
b5653bb
Compare
pkg/mimir/modules.go
Outdated
// Use either the Prometheus engine or Mimir Query Engine (with optional fallback to Prometheus | ||
// if it has been configured) for middlewares that require executing queries using a PromQL engine. | ||
var eng promql.QueryEngine | ||
switch t.Cfg.Querier.QueryEngine { | ||
case querier.PrometheusEngine: | ||
eng = promql.NewEngine(promOpts) | ||
case querier.MimirEngine: | ||
streamingEngine, err := streamingpromql.NewEngine(mqeOpts, streamingpromql.NewStaticQueryLimitsProvider(0), stats.NewQueryMetrics(mqeOpts.CommonOpts.Reg), nil, util_log.Logger) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to create Mimir Query Engine: %w", err) | ||
} | ||
|
||
engineOpts, _ := engine.NewPromQLEngineOptions(t.Cfg.Querier.EngineConfig, t.ActivityTracker, util_log.Logger, promqlEngineRegisterer) | ||
if t.Cfg.Querier.EnableQueryEngineFallback { | ||
eng = streamingpromqlcompat.NewEngineWithFallback(streamingEngine, promql.NewEngine(promOpts), nil, util_log.Logger) | ||
} else { | ||
eng = streamingEngine | ||
} | ||
default: | ||
panic(fmt.Sprintf("invalid config not caught by validation: unknown PromQL engine '%s'", t.Cfg.Querier.QueryEngine)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have similar logic in querier.New
- should we extract this to a shared method somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was avoiding this because of the panic and the number of parameters required means this would be kinda gross. I can see how it looks.
8f40489
to
62c1bf2
Compare
💻 Deploy preview deleted. |
c07f9e7
to
1e3b6cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM.
Do we need to do anything to support the X-Mimir-Force-Prometheus-Engine
header?
I didn't know about that header so we probably do 🤦 . I'll look into it. |
Introduce configuration to allow the Mimir Query Engine to be used instead of the Prometheus engine in the query-frontend when queries are rewritten to be shardable or subqueries are spun off. Notable changes: * New configuration for query-frontend to allow MQE to be used with an optional fallback to the Prometheus engine (same as in queriers). * Context timeouts are now checked at least once in `Selector` and also every 128 series instead of only every 128 series. * Query-frontend tests that used a query engine now run with both Prometheus and MQE engines. Results are expected to be the same in most cases, excluding some minor differences like error messages.
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
8210b34
to
d70fca9
Compare
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
#### What this PR does This PR fixes an issue where query-frontends running with MQE enabled do not emit query fallback metrics such as `cortex_mimir_query_engine_supported_queries_total` or `cortex_mimir_query_engine_unsupported_queries_total`. #### Which issue(s) this PR fixes or relates to #11417 #### Checklist - [n/a] Tests updated. - [n/a] Documentation added. - [x] `CHANGELOG.md` updated - the order of entries should be `[CHANGE]`, `[FEATURE]`, `[ENHANCEMENT]`, `[BUGFIX]`. If changelog entry is not needed, please add the `changelog-not-needed` label to the PR. - [n/a] [`about-versioning.md`](https://github.com/grafana/mimir/blob/main/docs/sources/mimir/configure/about-versioning.md) updated with experimental features.
…ts log messages (#12251) #### What this PR does The query-frontend emits a `query stats` log message after each query request is completed. MQE also emits a `query stats` log message after evaluation is completed. With MQE now running in query-frontends, this is potentially confusing, so I've changed the log message from MQE to `evaluation stats` to make it unambiguous. #### Which issue(s) this PR fixes or relates to #11417 #### Checklist - [x] Tests updated. - [n/a] Documentation added. - [n/a] `CHANGELOG.md` updated - the order of entries should be `[CHANGE]`, `[FEATURE]`, `[ENHANCEMENT]`, `[BUGFIX]`. If changelog entry is not needed, please add the `changelog-not-needed` label to the PR. - [n/a] [`about-versioning.md`](https://github.com/grafana/mimir/blob/main/docs/sources/mimir/configure/about-versioning.md) updated with experimental features.
Fix a copy/paste error from when MQE was added to the query-frontend. Related #11417
Fix a copy/paste error from when MQE was added to the query-frontend. Related #11417
What this PR does
Introduce configuration to allow the Mimir Query Engine to be used instead of the Prometheus engine in the query-frontend when queries are rewritten to be shardable or subqueries are spun off.
Notable changes:
Selector
and also every 128 series instead of only every 128 series.Which issue(s) this PR fixes or relates to
N/A
Notes to reviewers
There are a lot of whitespace changes in test files: click "hide whitespace changes" when reviewing.
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.