From 9b2aa6c00006ea04b4571ca95111cbda9bdc690c Mon Sep 17 00:00:00 2001 From: Jan Willies Date: Wed, 1 Nov 2023 18:46:37 +0100 Subject: [PATCH] make rulerAPIPath configurable (#19) * make rulerAPIPath configurable Co-authored-by: Friedrich Gonzalez Signed-off-by: Jan Willies * Include flags for ruler command Signed-off-by: Friedrich Gonzalez --------- Signed-off-by: Jan Willies Signed-off-by: Friedrich Gonzalez Co-authored-by: Friedrich Gonzalez --- pkg/client/client.go | 4 ++++ pkg/commands/rules.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/pkg/client/client.go b/pkg/client/client.go index c225569fa..fb055d377 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -35,6 +35,7 @@ type Config struct { TLS tls.ClientConfig UseLegacyRoutes bool `yaml:"use_legacy_routes"` AuthToken string `yaml:"auth_token"` + RulerAPIPath string `yaml:"ruler_api_path"` } // CortexClient is used to get and load rules into a cortex ruler @@ -82,6 +83,9 @@ func New(cfg Config) (*CortexClient, error) { } path := rulerAPIPath + if cfg.RulerAPIPath != "" { + path = cfg.RulerAPIPath + } if cfg.UseLegacyRoutes { path = legacyAPIPath } diff --git a/pkg/commands/rules.go b/pkg/commands/rules.go index 9a7b211e0..94c1a42ce 100644 --- a/pkg/commands/rules.go +++ b/pkg/commands/rules.go @@ -142,6 +142,11 @@ func (r *RuleCommand) Register(app *kingpin.Application) { Envar("CORTEX_USE_LEGACY_ROUTES"). BoolVar(&r.ClientConfig.UseLegacyRoutes) + c.Flag("ruler-api-path", "if set, API requests to cortex will use an alternative path for the ruler API, alternatively set CORTEX_RULER_API_PATH. The default is /api/v1/rules"). + Default(""). + Envar("CORTEX_RULER_API_PATH"). + StringVar(&r.ClientConfig.RulerAPIPath) + c.Flag("tls-ca-path", "TLS CA certificate to verify cortex API as part of mTLS, alternatively set CORTEX_TLS_CA_PATH."). Default(""). Envar("CORTEX_TLS_CA_CERT").