From e6cd90d6205331180018d4191eac49217b3d271c Mon Sep 17 00:00:00 2001 From: Owen Diehl Date: Tue, 10 Aug 2021 15:19:28 -0400 Subject: [PATCH 1/3] unmark the ruler api as experimental --- docs/sources/configuration/_index.md | 3 +-- docs/sources/rules/_index.md | 2 +- vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/sources/configuration/_index.md b/docs/sources/configuration/_index.md index 0321fd8eff3b..ff8f40776ccd 100644 --- a/docs/sources/configuration/_index.md +++ b/docs/sources/configuration/_index.md @@ -372,7 +372,6 @@ results_cache: The `ruler_config` configures the Loki ruler. -The Ruler API is experimental. ```yaml # URL of alerts return path. @@ -753,7 +752,7 @@ ring: [flush_period: | default = 1m] # Enable the Ruler API. -# CLI flag: -experimental.ruler.enable-api +# CLI flag: -ruler.enable-api [enable_api: | default = false] ``` diff --git a/docs/sources/rules/_index.md b/docs/sources/rules/_index.md index fe4c94ab7648..92cc527a5394 100644 --- a/docs/sources/rules/_index.md +++ b/docs/sources/rules/_index.md @@ -255,7 +255,7 @@ jobs: One option to scale the Ruler is by scaling it horizontally. However, with multiple Ruler instances running they will need to coordinate to determine which instance will evaluate which rule. Similar to the ingesters, the Rulers establish a hash ring to divide up the responsibilities of evaluating rules. -The possible configurations are listed fully in the [configuration documentation](https://grafana.com/docs/loki/latest/configuration/), but in order to shard rules across multiple Rulers, the rules API must be enabled via flag (`-experimental.Ruler.enable-api`) or config file parameter. Secondly, the Ruler requires it's own ring be configured. From there the Rulers will shard and handle the division of rules automatically. Unlike ingesters, Rulers do not hand over responsibility: all rules are re-sharded randomly every time a Ruler is added to or removed from the ring. +The possible configurations are listed fully in the [configuration documentation](https://grafana.com/docs/loki/latest/configuration/), but in order to shard rules across multiple Rulers, the rules API must be enabled via flag (`-ruler.enable-api`) or config file parameter. Secondly, the Ruler requires it's own ring be configured. From there the Rulers will shard and handle the division of rules automatically. Unlike ingesters, Rulers do not hand over responsibility: all rules are re-sharded randomly every time a Ruler is added to or removed from the ring. A full sharding-enabled Ruler example is: diff --git a/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go b/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go index 57b51ed103cd..1ade73876f4f 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go @@ -167,7 +167,12 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.StringVar(&cfg.ShardingStrategy, "ruler.sharding-strategy", util.ShardingStrategyDefault, fmt.Sprintf("The sharding strategy to use. Supported values are: %s.", strings.Join(supportedShardingStrategies, ", "))) f.DurationVar(&cfg.FlushCheckPeriod, "ruler.flush-period", 1*time.Minute, "Period with which to attempt to flush rule groups.") f.StringVar(&cfg.RulePath, "ruler.rule-path", "/rules", "file path to store temporary rule files for the prometheus rule managers") + + // Deprecated: this API is no longer experimental, but we'll register it under both flags for now. + // TODO(owen-d, 3.0.0): remove deprecated experimental prefix f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler api") + f.BoolVar(&cfg.EnableAPI, "ruler.enable-api", false, "Enable the ruler api") + f.DurationVar(&cfg.OutageTolerance, "ruler.for-outage-tolerance", time.Hour, `Max time to tolerate outage for restoring "for" state of alert.`) f.DurationVar(&cfg.ForGracePeriod, "ruler.for-grace-period", 10*time.Minute, `Minimum duration between alert and restored "for" state. This is maintained only for alerts with configured "for" time greater than grace period.`) f.DurationVar(&cfg.ResendDelay, "ruler.resend-delay", time.Minute, `Minimum amount of time to wait before resending an alert to Alertmanager.`) From 8e6da98708008be412e580598086a50a5f4a7cec Mon Sep 17 00:00:00 2001 From: Owen Diehl Date: Tue, 10 Aug 2021 15:20:50 -0400 Subject: [PATCH 2/3] deprecation notice for experimental prefix --- vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go b/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go index 1ade73876f4f..34c04f1a7f7b 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go @@ -170,7 +170,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { // Deprecated: this API is no longer experimental, but we'll register it under both flags for now. // TODO(owen-d, 3.0.0): remove deprecated experimental prefix - f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler api") + f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler api. Now available as ruler.enable-api and no longer marked as experimental. The experimental prefix will be deprecated and removed in the next major Loki release.") f.BoolVar(&cfg.EnableAPI, "ruler.enable-api", false, "Enable the ruler api") f.DurationVar(&cfg.OutageTolerance, "ruler.for-outage-tolerance", time.Hour, `Max time to tolerate outage for restoring "for" state of alert.`) From 9795da1160eedfbf11890776cb9688343e995304 Mon Sep 17 00:00:00 2001 From: Owen Diehl Date: Wed, 18 Aug 2021 11:21:19 -0400 Subject: [PATCH 3/3] removes vendor changes, adds -ruler.enable-api (without experimental prefix) on our ruler.Config --- pkg/ruler/config.go | 3 +++ vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/ruler/config.go b/pkg/ruler/config.go index 8a40c77e5d95..d7b060bee673 100644 --- a/pkg/ruler/config.go +++ b/pkg/ruler/config.go @@ -18,6 +18,9 @@ type Config struct { func (c *Config) RegisterFlags(f *flag.FlagSet) { c.Config.RegisterFlags(f) c.RemoteWrite.RegisterFlags(f) + + // TODO(owen-d, 3.0.0): remove deprecated experimental prefix in Cortex if they'll accept it. + f.BoolVar(&c.Config.EnableAPI, "ruler.enable-api", false, "Enable the ruler api") } // Validate overrides the embedded cortex variant which expects a cortex limits struct. Instead copy the relevant bits over. diff --git a/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go b/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go index 34c04f1a7f7b..57b51ed103cd 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go +++ b/vendor/github.com/cortexproject/cortex/pkg/ruler/ruler.go @@ -167,12 +167,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.StringVar(&cfg.ShardingStrategy, "ruler.sharding-strategy", util.ShardingStrategyDefault, fmt.Sprintf("The sharding strategy to use. Supported values are: %s.", strings.Join(supportedShardingStrategies, ", "))) f.DurationVar(&cfg.FlushCheckPeriod, "ruler.flush-period", 1*time.Minute, "Period with which to attempt to flush rule groups.") f.StringVar(&cfg.RulePath, "ruler.rule-path", "/rules", "file path to store temporary rule files for the prometheus rule managers") - - // Deprecated: this API is no longer experimental, but we'll register it under both flags for now. - // TODO(owen-d, 3.0.0): remove deprecated experimental prefix - f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler api. Now available as ruler.enable-api and no longer marked as experimental. The experimental prefix will be deprecated and removed in the next major Loki release.") - f.BoolVar(&cfg.EnableAPI, "ruler.enable-api", false, "Enable the ruler api") - + f.BoolVar(&cfg.EnableAPI, "experimental.ruler.enable-api", false, "Enable the ruler api") f.DurationVar(&cfg.OutageTolerance, "ruler.for-outage-tolerance", time.Hour, `Max time to tolerate outage for restoring "for" state of alert.`) f.DurationVar(&cfg.ForGracePeriod, "ruler.for-grace-period", 10*time.Minute, `Minimum duration between alert and restored "for" state. This is maintained only for alerts with configured "for" time greater than grace period.`) f.DurationVar(&cfg.ResendDelay, "ruler.resend-delay", time.Minute, `Minimum amount of time to wait before resending an alert to Alertmanager.`)