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

Rule: Added a new flag for max-source-resolution #7080

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 15 additions & 11 deletions cmd/thanos/rule.go
Expand Up @@ -95,16 +95,17 @@ type ruleConfig struct {

rwConfig *extflag.PathOrContent

resendDelay time.Duration
evalInterval time.Duration
outageTolerance time.Duration
forGracePeriod time.Duration
ruleFiles []string
objStoreConfig *extflag.PathOrContent
dataDir string
lset labels.Labels
ignoredLabelNames []string
storeRateLimits store.SeriesSelectLimits
resendDelay time.Duration
evalInterval time.Duration
outageTolerance time.Duration
forGracePeriod time.Duration
ruleFiles []string
maxSourceResolution string
objStoreConfig *extflag.PathOrContent
dataDir string
lset labels.Labels
ignoredLabelNames []string
storeRateLimits store.SeriesSelectLimits
}

type Expression struct {
Expand Down Expand Up @@ -139,6 +140,7 @@ func registerRule(app *extkingpin.App) {
walCompression := cmd.Flag("tsdb.wal-compression", "Compress the tsdb WAL.").Default("true").Bool()

cmd.Flag("data-dir", "data directory").Default("data/").StringVar(&conf.dataDir)
cmd.Flag("max-source-resolution", "Max resolution wanted for the data queried.").StringVar(&conf.maxSourceResolution)
cmd.Flag("rule-file", "Rule files that should be used by rule manager. Can be in glob format (repeated). Note that rules are not automatically detected, use SIGHUP or do HTTP POST /-/reload to re-read them.").
Default("rules/").StringsVar(&conf.ruleFiles)
cmd.Flag("resend-delay", "Minimum amount of time to wait before resending an alert to Alertmanager.").
Expand Down Expand Up @@ -626,7 +628,7 @@ func runRule(
OutageTolerance: conf.outageTolerance,
ForGracePeriod: conf.forGracePeriod,
},
queryFuncCreator(logger, queryClients, promClients, grpcEndpointSet, metrics.duplicatedQuery, metrics.ruleEvalWarnings, conf.query.httpMethod, conf.query.doNotAddThanosParams),
queryFuncCreator(logger, queryClients, promClients, grpcEndpointSet, metrics.duplicatedQuery, metrics.ruleEvalWarnings, conf.query.httpMethod, conf.query.doNotAddThanosParams, conf.maxSourceResolution),
conf.lset,
// In our case the querying URL is the external URL because in Prometheus
// --web.external-url points to it i.e. it points at something where the user
Expand Down Expand Up @@ -891,6 +893,7 @@ func queryFuncCreator(
ruleEvalWarnings *prometheus.CounterVec,
httpMethod string,
doNotAddThanosParams bool,
maxSourceResolution string,
) func(partialResponseStrategy storepb.PartialResponseStrategy) rules.QueryFunc {

// queryFunc returns query function that hits the HTTP query API of query peers in randomized order until we get a result
Expand Down Expand Up @@ -919,6 +922,7 @@ func queryFuncCreator(
PartialResponseStrategy: partialResponseStrategy,
Method: httpMethod,
DoNotAddThanosParams: doNotAddThanosParams,
MaxSourceResolution: maxSourceResolution,
})
span.Finish()

Expand Down
2 changes: 2 additions & 0 deletions docs/components/rule.md
Expand Up @@ -370,6 +370,8 @@ Flags:
--log.format=logfmt Log format to use. Possible options: logfmt or
json.
--log.level=info Log filtering level.
--max-source-resolution=MAX-SOURCE-RESOLUTION
Max resolution wanted for the data queried.
--objstore.config=<content>
Alternative to 'objstore.config-file'
flag (mutually exclusive). Content of
Expand Down