Skip to content

Commit 9f00599

Browse files
authored
Fix alertmanager subcommand and path for the configuration API (#72)
* Fix the alertmanager subcommand Seems like it got unregistered as we renamed it. * Use the new alertmanager API path. In accordance with what is currently part of upstream Cortex. * Add a changelog entry
1 parent a454a6d commit 9f00599

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## unreleased / master
44

5+
* [BUGFIX] Fix alertmanager registration subcommand and path for the configuration API #72
6+
57
## v0.2.3
68

79
* [FEATURE] Added `alerts verify` command, which can be used to compare `ALERTS` series in Cortex to verify if Prometheus and Cortex Ruler are firing the same alerts

cmd/cortextool/main.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@ import (
99
)
1010

1111
var (
12-
ruleCommand commands.RuleCommand
13-
alertCommand commands.AlertCommand
14-
logConfig commands.LoggerConfig
15-
pushGateway commands.PushGatewayConfig
16-
loadgenCommand commands.LoadgenCommand
12+
ruleCommand commands.RuleCommand
13+
alertCommand commands.AlertCommand
14+
alertmanagerCommand commands.AlertmanagerCommand
15+
logConfig commands.LoggerConfig
16+
pushGateway commands.PushGatewayConfig
17+
loadgenCommand commands.LoadgenCommand
1718
)
1819

1920
func main() {
2021
kingpin.Version("0.1.3")
2122
app := kingpin.New("cortextool", "A command-line tool to manage cortex.")
2223
logConfig.Register(app)
2324
alertCommand.Register(app)
25+
alertmanagerCommand.Register(app)
2426
ruleCommand.Register(app)
2527
pushGateway.Register(app)
2628
loadgenCommand.Register(app)

pkg/client/alerts.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"gopkg.in/yaml.v2"
1010
)
1111

12+
const alertmanagerAPIPath = "/api/v1/alerts"
13+
1214
type configCompat struct {
1315
TemplateFiles map[string]string `yaml:"template_files"`
1416
AlertmanagerConfig string `yaml:"alertmanager_config"`
@@ -24,19 +26,19 @@ func (r *CortexClient) CreateAlertmanagerConfig(ctx context.Context, cfg string,
2426
return err
2527
}
2628

27-
_, err = r.doRequest("/alertmanager/alerts", "POST", payload)
29+
_, err = r.doRequest(alertmanagerAPIPath, "POST", payload)
2830
return err
2931
}
3032

3133
// DeleteAlermanagerConfig deletes the users alertmanagerconfig
3234
func (r *CortexClient) DeleteAlermanagerConfig(ctx context.Context) error {
33-
_, err := r.doRequest("/alertmanager/alerts", "DELETE", nil)
35+
_, err := r.doRequest(alertmanagerAPIPath, "DELETE", nil)
3436
return err
3537
}
3638

3739
// GetAlertmanagerConfig retrieves a rule group
3840
func (r *CortexClient) GetAlertmanagerConfig(ctx context.Context) (string, map[string]string, error) {
39-
res, err := r.doRequest("/alertmanager/alerts", "GET", nil)
41+
res, err := r.doRequest(alertmanagerAPIPath, "GET", nil)
4042
if err != nil {
4143
log.Debugln("no alert config present in response")
4244
return "", nil, err

0 commit comments

Comments
 (0)