Skip to content

Commit

Permalink
rule: add query offset for testing
Browse files Browse the repository at this point in the history
Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
  • Loading branch information
GiedriusS committed Dec 4, 2024
1 parent 0023fc2 commit aebd3e4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type ruleConfig struct {
ignoredLabelNames []string
storeRateLimits store.SeriesSelectLimits
ruleConcurrentEval int64
ruleGlobalOffset time.Duration

extendedFunctionsEnabled bool
}
Expand Down Expand Up @@ -158,6 +159,7 @@ func registerRule(app *extkingpin.App) {
cmd.Flag("restore-ignored-label", "Label names to be ignored when restoring alerts from the remote storage. This is only used in stateless mode.").
StringsVar(&conf.ignoredLabelNames)
cmd.Flag("rule-concurrent-evaluation", "How many rules can be evaluated concurrently. Default is 1.").Default("1").Int64Var(&conf.ruleConcurrentEval)
cmd.Flag("rule-global-offset", "Global offset to be added to each rule evaluation. Useful if you are using remote_write to help with ocassional ingestion latency.").Default("0s").DurationVar(&conf.ruleGlobalOffset)

Check failure on line 162 in cmd/thanos/rule.go

View workflow job for this annotation

GitHub Actions / Check misspelled words

ocassional ==> occasional

Check failure on line 162 in cmd/thanos/rule.go

View workflow job for this annotation

GitHub Actions / Linters (Static Analysis) for Go

`ocassional` is a misspelling of `occasional` (misspell)

cmd.Flag("grpc-query-endpoint", "Addresses of Thanos gRPC query API servers (repeatable). The scheme may be prefixed with 'dns+' or 'dnssrv+' to detect Thanos API servers through respective DNS lookups.").
PlaceHolder("<endpoint>").StringsVar(&conf.grpcQueryEndpoints)
Expand Down Expand Up @@ -640,6 +642,11 @@ func runRule(
managerOpts.MaxConcurrentEvals = conf.ruleConcurrentEval
managerOpts.ConcurrentEvalsEnabled = true
}
if conf.ruleGlobalOffset > 0 {
managerOpts.DefaultRuleQueryOffset = func() time.Duration {
return conf.ruleGlobalOffset
}
}

ctx, cancel := context.WithCancel(context.Background())
logger = log.With(logger, "component", "rules")
Expand Down

0 comments on commit aebd3e4

Please sign in to comment.