From a54c7c93dc89fcdb5349698fa1f0cfd4586889ce Mon Sep 17 00:00:00 2001 From: 00arthur00 Date: Tue, 8 Oct 2019 18:20:33 +0800 Subject: [PATCH] keep same logic with prometheus resend delay configuration Signed-off-by: 00arthur00 --- cmd/thanos/rule.go | 8 +++++++- docs/components/rule.md | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/thanos/rule.go b/cmd/thanos/rule.go index 1591542027..bf9344d399 100644 --- a/cmd/thanos/rule.go +++ b/cmd/thanos/rule.go @@ -70,7 +70,8 @@ func registerRule(m map[string]setupFunc, app *kingpin.Application) { ruleFiles := cmd.Flag("rule-file", "Rule files that should be used by rule manager. Can be in glob format (repeated)."). Default("rules/").Strings() - + resendDelay := modelDuration(cmd.Flag("resend-delay", "Minimum amount of time to wait before resending an alert to Alertmanager."). + Default("1m")) evalInterval := modelDuration(cmd.Flag("eval-interval", "The default evaluation interval to use."). Default("30s")) tsdbBlockDuration := modelDuration(cmd.Flag("tsdb.block-duration", "Block duration for TSDB block."). @@ -162,6 +163,7 @@ func registerRule(m map[string]setupFunc, app *kingpin.Application) { *webRoutePrefix, *webExternalPrefix, *webPrefixHeaderName, + time.Duration(*resendDelay), time.Duration(*evalInterval), *dataDir, *ruleFiles, @@ -196,6 +198,7 @@ func runRule( webRoutePrefix string, webExternalPrefix string, webPrefixHeaderName string, + resendDelay time.Duration, evalInterval time.Duration, dataDir string, ruleFiles []string, @@ -299,6 +302,8 @@ func runRule( } if !alrt.ResolvedAt.IsZero() { a.EndsAt = alrt.ResolvedAt + } else { + a.EndsAt = alrt.ValidUntil } res = append(res, a) } @@ -312,6 +317,7 @@ func runRule( Appendable: st, ExternalURL: nil, TSDB: st, + ResendDelay: resendDelay, } for _, strategy := range storepb.PartialResponseStrategy_value { diff --git a/docs/components/rule.md b/docs/components/rule.md index 10c159dc10..ba766090e0 100644 --- a/docs/components/rule.md +++ b/docs/components/rule.md @@ -188,6 +188,8 @@ Flags: --data-dir="data/" data directory --rule-file=rules/ ... Rule files that should be used by rule manager. Can be in glob format (repeated). + --resend-delay=1m Minimum amount of time to wait before resending + an alert to Alertmanager. --eval-interval=30s The default evaluation interval to use. --tsdb.block-duration=2h Block duration for TSDB block. --tsdb.retention=48h Block retention time on local disk.