Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit a5ffe9d

Browse files
Enable promql-per-step-stats feature.
Signed-off-by: Harkishen-Singh <[email protected]> This commit enables the `promql-per-step-stats` feature. This is done by passing `&QueryOpts{EnablePerStepStats: true}` when creating a query. This result goes with logical AND with `-enable-feature=promql-per-step-stats` applied as Promscale starts.
1 parent 041b5bb commit a5ffe9d

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ We use the following categories for changes:
1515

1616
## [Unreleased]
1717

18+
### Added
19+
- `-enable-feature=promql-per-step-stats` feature for statistics in PromQL evaluation
20+
1821
## [0.11.0] - 2022-05-11
1922

2023
## Added

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The following subsections cover all CLI flags which promscale supports. You can
4646
|---------------------------------|:------------------------------:|:-------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
4747
| cache.memory-target | unsigned-integer or percentage | 80% | Target for max amount of memory to use. Specified in bytes or as a percentage of system memory (e.g. 80%). |
4848
| config | string | config.yml | YAML configuration file path for Promscale. |
49-
| enable-feature | string | "" | Enable one or more experimental promscale features (as a comma-separated list). Current experimental features are `promql-at-modifier`, and `promql-negative-offset`. For more information, please consult the following resources: [promql-at-modifier](https://prometheus.io/docs/prometheus/latest/feature_flags/#modifier-in-promql), [promql-negative-offset](https://prometheus.io/docs/prometheus/latest/feature_flags/#negative-offset-in-promql). |
49+
| enable-feature | string | "" | Enable one or more experimental promscale features (as a comma-separated list). Current experimental features are `promql-at-modifier`, `promql-negative-offset` and `promql-per-step-stats`. For more information, please consult the following resources: [promql-at-modifier](https://prometheus.io/docs/prometheus/latest/feature_flags/#modifier-in-promql), [promql-negative-offset](https://prometheus.io/docs/prometheus/latest/feature_flags/#negative-offset-in-promql), [promql-per-step-stats](https://prometheus.io/docs/prometheus/latest/feature_flags/#per-step-stats). |
5050
| thanos.store-api.server-address | string | "" (disabled) | Address to listen on for Thanos Store API endpoints. |
5151
| tracing.otlp.server-address | string | ":9202" | Address to listen on for OpenTelemetry OTLP GRPC server. |
5252

pkg/api/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func queryHandler(queryEngine *promql.Engine, queryable promql.Queryable, update
5050
defer cancel()
5151
}
5252

53-
qry, err := queryEngine.NewInstantQuery(queryable, nil, r.FormValue("query"), ts)
53+
qry, err := queryEngine.NewInstantQuery(queryable, &promql.QueryOpts{EnablePerStepStats: true}, r.FormValue("query"), ts)
5454
if err != nil {
5555
log.Error("msg", "Query error", "err", err.Error())
5656
respondError(w, http.StatusBadRequest, err, "bad_data")

pkg/api/query_range.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func queryRange(promqlConf *query.Config, queryEngine *promql.Engine, queryable
8989

9090
qry, err := queryEngine.NewRangeQuery(
9191
queryable,
92-
nil,
92+
&promql.QueryOpts{EnablePerStepStats: true},
9393
r.FormValue("query"),
9494
start,
9595
end,

pkg/query/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type Config struct {
4242
}
4343

4444
func ParseFlags(fs *flag.FlagSet, cfg *Config) *Config {
45-
fs.Var(&cfg.PromscaleEnabledFeatureList, "enable-feature", "Enable beta/experimental features as a comma-separated list. Currently the following values can be passed: promql-at-modifier, promql-negative-offset")
45+
fs.Var(&cfg.PromscaleEnabledFeatureList, "enable-feature", "Enable beta/experimental features as a comma-separated list. Currently the following values can be passed: promql-at-modifier, promql-negative-offset, promql-per-step-stats")
4646

4747
fs.DurationVar(&cfg.MaxQueryTimeout, "metrics.promql.query-timeout", DefaultQueryTimeout, "Maximum time a query may take before being aborted. This option sets both the default and maximum value of the 'timeout' parameter in "+
4848
"'/api/v1/query.*' endpoints.")
@@ -61,7 +61,7 @@ func Validate(cfg *Config) error {
6161
cfg.EnabledFeatureMap = make(map[string]struct{})
6262
for _, f := range cfg.PromscaleEnabledFeatureList {
6363
switch f {
64-
case "promql-at-modifier", "promql-negative-offset":
64+
case "promql-at-modifier", "promql-negative-offset", "promql-per-step-stats":
6565
cfg.EnabledFeatureMap[f] = struct{}{}
6666
case "tracing":
6767
log.Error("msg", "tracing feature is now on by default, no need to use it with --enable-feature flag")

pkg/query/query_engine.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ func NewEngine(logger log.Logger, queryTimeout, lookBackDelta, subqueryDefaultSt
2121
LookbackDelta: lookBackDelta,
2222
NoStepSubqueryIntervalFn: func(int64) int64 { return durationMilliseconds(subqueryDefaultStepInterval) },
2323
}
24-
// todo (harkishen): add promql-per-step-stats feature
24+
2525
_, engineOpts.EnableAtModifier = enabledFeaturesMap["promql-at-modifier"]
2626
_, engineOpts.EnableNegativeOffset = enabledFeaturesMap["promql-negative-offset"]
27+
_, engineOpts.EnablePerStepStats = enabledFeaturesMap["promql-per-step-stats"]
2728
return promql.NewEngine(engineOpts), nil
2829
}
2930

pkg/runner/flags_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,15 @@ func TestParseFlags(t *testing.T) {
155155
},
156156
{
157157
name: "enable feature should populate map of enabled features",
158-
args: []string{"-enable-feature", "tracing,promql-at-modifier,promql-negative-offset", "-tracing.otlp.server-address", "someaddress"},
158+
args: []string{"-enable-feature", "tracing,promql-at-modifier,promql-negative-offset,promql-per-step-stats", "-tracing.otlp.server-address", "someaddress"},
159159
result: func(c Config) Config {
160160
c.OTLPGRPCListenAddr = "someaddress"
161161
c.PromQLCfg.EnabledFeatureMap = map[string]struct{}{
162162
"promql-at-modifier": {},
163163
"promql-negative-offset": {},
164+
"promql-per-step-stats": {},
164165
}
165-
c.PromQLCfg.PromscaleEnabledFeatureList = []string{"tracing", "promql-at-modifier", "promql-negative-offset"}
166+
c.PromQLCfg.PromscaleEnabledFeatureList = []string{"tracing", "promql-at-modifier", "promql-negative-offset", "promql-per-step-stats"}
166167
return c
167168
},
168169
},

0 commit comments

Comments
 (0)