Skip to content

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

heysujal
Copy link

@heysujal heysujal commented Apr 5, 2025

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Fixes #7640

In thanos/query.go

  1. Added "promql-experimental-functions" in query.go
  2. Added cmd.Flag for enableQueryExperimentalFunctions
  3. Updated FeatureList Description
  4. Added logger for promqlExperimentalFunctions flag
  5. Updated query builder for the same

Added entry for the same in pkg/api/query/engine.go , pkg/queryfrontend/config.go, and test/e2e/e2ethanos/services.go

Verification

@heysujal heysujal marked this pull request as draft April 5, 2025 20:40
@heysujal heysujal marked this pull request as ready for review April 9, 2025 18:00
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.

Please fix build

heysujal and others added 6 commits April 19, 2025 23:36
Signed-off-by: Sujal Gupta <[email protected]>
Signed-off-by: Sujal Gupta <[email protected]>
Adjust the default get-config timeout to match the default get-config
interval.

Signed-off-by: Michael Hoffmann <[email protected]>
Signed-off-by: Sujal Gupta <[email protected]>
Signed-off-by: Sujal Gupta <[email protected]>
@heysujal heysujal requested a review from yeya24 April 19, 2025 18:22
Comment on lines +97 to +99
// Set global experimental functions flag
parser.EnableExperimentalFunctions = enablePromQLExperimentalFunctions

Copy link
Contributor

@Saumya40-codes Saumya40-codes Apr 27, 2025

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

@Saumya40-codes Saumya40-codes Apr 27, 2025

Choose a reason for hiding this comment

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

Perhaps, adding a new field in engine struct like EnableExperimentalFunctions might be a good way if want to continue with later 👀

https://github.com/thanos-io/promql-engine/blob/main/engine/engine.go#L57C1-L84C2 and then when we do engine.New we can use this logic there (parser.EnableExperimentalFunctions=EnableExperimentalFunctions)

Copy link
Member

Choose a reason for hiding this comment

The 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? 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right!

Current looks to be right then
We can resolve this!

@@ -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()
Copy link
Member

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

Comment on lines +97 to +99
// Set global experimental functions flag
parser.EnableExperimentalFunctions = enablePromQLExperimentalFunctions

Copy link
Member

Choose a reason for hiding this comment

The 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? 🙂

@@ -317,6 +318,7 @@ func registerQuery(app *extkingpin.App) {
*enableTargetPartialResponse,
*enableMetricMetadataPartialResponse,
*enableExemplarPartialResponse,
false,
Copy link
Contributor

@Saumya40-codes Saumya40-codes Apr 28, 2025

Choose a reason for hiding this comment

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

if --enable-feature=promql-experimental-functions is set, this will still take it as false.

https://github.com/thanos-io/thanos/pull/8191/files#diff-f9808a0ac67a474a18f6a7ea767593f85c216aeafe322c1ff5d17c81ababff95R211-R221

maybe we can intercept by checking from here if the set value is promql-experimental-functions and pass true/false based on that.

DefaultTenant string
TenantCertField string
EnableXFunctions bool
EnableQueryExperimentalFunctions bool
Copy link
Contributor

@Saumya40-codes Saumya40-codes Apr 28, 2025

Choose a reason for hiding this comment

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

we can use this field at cmd/thanos/query_frontend.go now

e.g. https://github.com/thanos-io/thanos/blob/main/cmd/thanos/query_frontend.go#L161

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.

FT add feature flag for 'promql-experimental-functions'.
5 participants