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

Fix alertmanager subcommand and path for the configuration API #72

Merged
merged 3 commits into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## unreleased / master

* [BUGFIX] Fix alertmanager registration subcommand and path for the configuration API #72

## v0.2.3

* [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
Expand Down
12 changes: 7 additions & 5 deletions cmd/cortextool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ import (
)

var (
ruleCommand commands.RuleCommand
alertCommand commands.AlertCommand
logConfig commands.LoggerConfig
pushGateway commands.PushGatewayConfig
loadgenCommand commands.LoadgenCommand
ruleCommand commands.RuleCommand
alertCommand commands.AlertCommand
alertmanagerCommand commands.AlertmanagerCommand
logConfig commands.LoggerConfig
pushGateway commands.PushGatewayConfig
loadgenCommand commands.LoadgenCommand
)

func main() {
kingpin.Version("0.1.3")
app := kingpin.New("cortextool", "A command-line tool to manage cortex.")
logConfig.Register(app)
alertCommand.Register(app)
alertmanagerCommand.Register(app)
ruleCommand.Register(app)
pushGateway.Register(app)
loadgenCommand.Register(app)
Expand Down
8 changes: 5 additions & 3 deletions pkg/client/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"gopkg.in/yaml.v2"
)

const alertmanagerAPIPath = "/api/v1/alerts"

type configCompat struct {
TemplateFiles map[string]string `yaml:"template_files"`
AlertmanagerConfig string `yaml:"alertmanager_config"`
Expand All @@ -24,19 +26,19 @@ func (r *CortexClient) CreateAlertmanagerConfig(ctx context.Context, cfg string,
return err
}

_, err = r.doRequest("/alertmanager/alerts", "POST", payload)
_, err = r.doRequest(alertmanagerAPIPath, "POST", payload)
return err
}

// DeleteAlermanagerConfig deletes the users alertmanagerconfig
func (r *CortexClient) DeleteAlermanagerConfig(ctx context.Context) error {
_, err := r.doRequest("/alertmanager/alerts", "DELETE", nil)
_, err := r.doRequest(alertmanagerAPIPath, "DELETE", nil)
return err
}

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