-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Query: Enable promql-experimental-functions #8191
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
base: main
Are you sure you want to change the base?
Changes from all commits
8aff32e
e5b0d3c
95f9ce6
f53f873
f85b8e7
706b3c2
194f433
38bc09c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,9 +53,10 @@ import ( | |
) | ||
|
||
const ( | ||
promqlNegativeOffset = "promql-negative-offset" | ||
promqlAtModifier = "promql-at-modifier" | ||
queryPushdown = "query-pushdown" | ||
promqlNegativeOffset = "promql-negative-offset" | ||
promqlAtModifier = "promql-at-modifier" | ||
queryPushdown = "query-pushdown" | ||
promqlExperimentalFunctions = "promql-experimental-functions" | ||
) | ||
|
||
// registerQuery registers a query command. | ||
|
@@ -135,7 +136,7 @@ func registerQuery(app *extkingpin.App) { | |
|
||
activeQueryDir := cmd.Flag("query.active-query-path", "Directory to log currently active queries in the queries.active file.").Default("").String() | ||
|
||
featureList := cmd.Flag("enable-feature", "Comma separated experimental feature names to enable.The current list of features is empty.").Hidden().Default("").Strings() | ||
featureList := cmd.Flag("enable-feature", "Comma separated experimental feature names to enable. The current list of features is: promql-experimental-functions (enables experimental PromQL functions).").Hidden().Default("").Strings() | ||
|
||
enableExemplarPartialResponse := cmd.Flag("exemplar.partial-response", "Enable partial response for exemplar endpoint. --no-exemplar.partial-response for disabling."). | ||
Hidden().Default("true").Bool() | ||
|
@@ -317,6 +318,7 @@ func registerQuery(app *extkingpin.App) { | |
*enableTargetPartialResponse, | ||
*enableMetricMetadataPartialResponse, | ||
*enableExemplarPartialResponse, | ||
false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if maybe we can intercept by checking from here if the set value is |
||
*activeQueryDir, | ||
time.Duration(*instantDefaultMaxSourceResolution), | ||
*defaultMetadataTimeRange, | ||
|
@@ -379,6 +381,7 @@ func runQuery( | |
enableTargetPartialResponse bool, | ||
enableMetricMetadataPartialResponse bool, | ||
enableExemplarPartialResponse bool, | ||
enableQueryExperimentalFunctions bool, | ||
activeQueryDir string, | ||
instantDefaultMaxSourceResolution time.Duration, | ||
defaultMetadataTimeRange time.Duration, | ||
|
@@ -464,6 +467,7 @@ func runQuery( | |
lookbackDelta, | ||
defaultEvaluationInterval, | ||
extendedFunctionsEnabled, | ||
enableQueryExperimentalFunctions, | ||
activeQueryTracker, | ||
queryMode, | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ import ( | |
"github.com/go-kit/log" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/prometheus/promql" | ||
"github.com/prometheus/prometheus/promql/parser" | ||
"github.com/prometheus/prometheus/storage" | ||
|
||
"github.com/thanos-io/promql-engine/api" | ||
|
@@ -88,10 +89,14 @@ func NewQueryFactory( | |
lookbackDelta time.Duration, | ||
evaluationInterval time.Duration, | ||
enableXFunctions bool, | ||
enablePromQLExperimentalFunctions bool, | ||
activeQueryTracker *promql.ActiveQueryTracker, | ||
mode PromqlQueryMode, | ||
) *QueryFactory { | ||
makeOpts := func(registry prometheus.Registerer) engine.Opts { | ||
// Set global experimental functions flag | ||
parser.EnableExperimentalFunctions = enablePromQLExperimentalFunctions | ||
|
||
Comment on lines
+97
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a Question: As I was working with this in engine (re: thanos-io/promql-engine#547) wonder if its ok to have this flag set logic in thanos side or we should keep parser related logic limited to engine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps, adding a new field in engine struct like https://github.com/thanos-io/promql-engine/blob/main/engine/engine.go#L57C1-L84C2 and then when we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it sets the global in parser package, wouldn't that reflect everywhere (including in the thanos engine)? I think this is an ok pattern to follow. Would having extra option on the engine struct help other cases? 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right! Current looks to be right then |
||
opts := engine.Opts{ | ||
EngineOpts: promql.EngineOpts{ | ||
Logger: logutil.GoKitLogToSlog(logger), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,7 @@ var ( | |
5*time.Minute, | ||
30*time.Second, | ||
true, | ||
false, | ||
nil, | ||
PromqlQueryModeLocal, | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,17 +202,18 @@ type Config struct { | |
LabelsConfig | ||
DownstreamTripperConfig | ||
|
||
CortexHandlerConfig *transport.HandlerConfig | ||
CompressResponses bool | ||
CacheCompression string | ||
RequestLoggingDecision string | ||
DownstreamURL string | ||
ForwardHeaders []string | ||
NumShards int | ||
TenantHeader string | ||
DefaultTenant string | ||
TenantCertField string | ||
EnableXFunctions bool | ||
CortexHandlerConfig *transport.HandlerConfig | ||
CompressResponses bool | ||
CacheCompression string | ||
RequestLoggingDecision string | ||
DownstreamURL string | ||
ForwardHeaders []string | ||
NumShards int | ||
TenantHeader string | ||
DefaultTenant string | ||
TenantCertField string | ||
EnableXFunctions bool | ||
EnableQueryExperimentalFunctions bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can use this field at e.g. https://github.com/thanos-io/thanos/blob/main/cmd/thanos/query_frontend.go#L161 |
||
} | ||
|
||
// QueryRangeConfig holds the config for query range tripperware. | ||
|
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.
Does this flag still need to be hidden, I wonder