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

[r313] MQE: subqueries #9684

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* `cortex_alertmanager_alerts`
* `cortex_alertmanager_silences`
* [CHANGE] Distributor: Drop experimental `-distributor.direct-otlp-translation-enabled` flag, since direct OTLP translation is well tested at this point. #9647
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #9367 #9368 #9398 #9399 #9403 #9417 #9418 #9419 #9420 #9482 #9504 #9505 #9507 #9518 #9531 #9532 #9533 #9553 #9558 #9588 #9589 #9639 #9641 #9642
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #9367 #9368 #9398 #9399 #9403 #9417 #9418 #9419 #9420 #9482 #9504 #9505 #9507 #9518 #9531 #9532 #9533 #9553 #9558 #9588 #9589 #9639 #9641 #9642 #9664
* [FEATURE] Query-frontend: added experimental configuration options `query-frontend.cache-errors` and `query-frontend.results-cache-ttl-for-errors` to allow non-transient responses to be cached. When set to `true` error responses from hitting limits or bad data are cached for a short TTL. #9028
* [FEATURE] gRPC: Support S2 compression. #9322
* `-alertmanager.alertmanager-client.grpc-compression=s2`
Expand Down
11 changes: 11 additions & 0 deletions cmd/mimir/config-descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,17 @@
"fieldFlag": "querier.mimir-query-engine.enable-scalars",
"fieldType": "boolean",
"fieldCategory": "experimental"
},
{
"kind": "field",
"name": "enable_subqueries",
"required": false,
"desc": "Enable support for subqueries in Mimir's query engine. Only applies if the Mimir query engine is in use.",
"fieldValue": null,
"fieldDefaultValue": true,
"fieldFlag": "querier.mimir-query-engine.enable-subqueries",
"fieldType": "boolean",
"fieldCategory": "experimental"
}
],
"fieldValue": null,
Expand Down
2 changes: 2 additions & 0 deletions cmd/mimir/help-all.txt.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,8 @@ Usage of ./cmd/mimir/mimir:
[experimental] Enable support for binary comparison operations between two scalars in Mimir's query engine. Only applies if the Mimir query engine is in use. (default true)
-querier.mimir-query-engine.enable-scalars
[experimental] Enable support for scalars in Mimir's query engine. Only applies if the Mimir query engine is in use. (default true)
-querier.mimir-query-engine.enable-subqueries
[experimental] Enable support for subqueries in Mimir's query engine. Only applies if the Mimir query engine is in use. (default true)
-querier.mimir-query-engine.enable-vector-scalar-binary-comparison-operations
[experimental] Enable support for binary comparison operations between a vector and a scalar in Mimir's query engine. Only applies if the Mimir query engine is in use. (default true)
-querier.mimir-query-engine.enable-vector-vector-binary-comparison-operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,11 @@ mimir_query_engine:
# applies if the Mimir query engine is in use.
# CLI flag: -querier.mimir-query-engine.enable-scalars
[enable_scalars: <boolean> | default = true]

# (experimental) Enable support for subqueries in Mimir's query engine. Only
# applies if the Mimir query engine is in use.
# CLI flag: -querier.mimir-query-engine.enable-subqueries
[enable_subqueries: <boolean> | default = true]
```

### frontend
Expand Down
10 changes: 10 additions & 0 deletions pkg/streamingpromql/benchmarks/benchmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ func TestCases(metricSizes []int) []BenchCase {
//{
// Expr: "absent_over_time(a_X[1d])",
//},
// Subqueries.
{
Expr: "sum_over_time(a_X[10m:3m])",
},
{
Expr: "sum_over_time(nh_X[10m:3m])",
},
{
Expr: "sum(sum_over_time(a_X[10m:3m]))",
},
//// Unary operators.
//{
// Expr: "-a_X",
Expand Down
3 changes: 3 additions & 0 deletions pkg/streamingpromql/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type FeatureToggles struct {
EnableScalarScalarBinaryComparisonOperations bool `yaml:"enable_scalar_scalar_binary_comparison_operations" category:"experimental"`
EnableBinaryLogicalOperations bool `yaml:"enable_binary_logical_operations" category:"experimental"`
EnableScalars bool `yaml:"enable_scalars" category:"experimental"`
EnableSubqueries bool `yaml:"enable_subqueries" category:"experimental"`
}

// EnableAllFeatures enables all features supported by MQE, including experimental or incomplete features.
Expand All @@ -35,6 +36,7 @@ var EnableAllFeatures = FeatureToggles{
true,
true,
true,
true,
}

func (t *FeatureToggles) RegisterFlags(f *flag.FlagSet) {
Expand All @@ -44,4 +46,5 @@ func (t *FeatureToggles) RegisterFlags(f *flag.FlagSet) {
f.BoolVar(&t.EnableScalarScalarBinaryComparisonOperations, "querier.mimir-query-engine.enable-scalar-scalar-binary-comparison-operations", true, "Enable support for binary comparison operations between two scalars in Mimir's query engine. Only applies if the Mimir query engine is in use.")
f.BoolVar(&t.EnableBinaryLogicalOperations, "querier.mimir-query-engine.enable-binary-logical-operations", true, "Enable support for binary logical operations in Mimir's query engine. Only applies if the Mimir query engine is in use.")
f.BoolVar(&t.EnableScalars, "querier.mimir-query-engine.enable-scalars", true, "Enable support for scalars in Mimir's query engine. Only applies if the Mimir query engine is in use.")
f.BoolVar(&t.EnableSubqueries, "querier.mimir-query-engine.enable-subqueries", true, "Enable support for subqueries in Mimir's query engine. Only applies if the Mimir query engine is in use.")
}
22 changes: 12 additions & 10 deletions pkg/streamingpromql/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ func NewEngine(opts EngineOpts, limitsProvider QueryLimitsProvider, metrics *sta
}

return &Engine{
lookbackDelta: lookbackDelta,
timeout: opts.CommonOpts.Timeout,
limitsProvider: limitsProvider,
activeQueryTracker: opts.CommonOpts.ActiveQueryTracker,
featureToggles: opts.FeatureToggles,
lookbackDelta: lookbackDelta,
timeout: opts.CommonOpts.Timeout,
limitsProvider: limitsProvider,
activeQueryTracker: opts.CommonOpts.ActiveQueryTracker,
featureToggles: opts.FeatureToggles,
noStepSubqueryIntervalFn: opts.CommonOpts.NoStepSubqueryIntervalFn,

logger: logger,
estimatedPeakMemoryConsumption: promauto.With(opts.CommonOpts.Reg).NewHistogram(prometheus.HistogramOpts{
Expand All @@ -64,11 +65,12 @@ func NewEngine(opts EngineOpts, limitsProvider QueryLimitsProvider, metrics *sta
}

type Engine struct {
lookbackDelta time.Duration
timeout time.Duration
limitsProvider QueryLimitsProvider
activeQueryTracker promql.QueryTracker
featureToggles FeatureToggles
lookbackDelta time.Duration
timeout time.Duration
limitsProvider QueryLimitsProvider
activeQueryTracker promql.QueryTracker
featureToggles FeatureToggles
noStepSubqueryIntervalFn func(rangeMillis int64) int64

logger log.Logger
estimatedPeakMemoryConsumption prometheus.Histogram
Expand Down
Loading
Loading