-
Notifications
You must be signed in to change notification settings - Fork 630
Alertmanager configuration validate-only mode #3437 #3440
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
Alertmanager configuration validate-only mode #3437 #3440
Conversation
docs/sources/operators-guide/architecture/components/alertmanager.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit
…ger.md Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com>
I liked the suggestion you had in the issue about |
Let me take a look at that. Certainly sounds reasonable as the id/address is a little ugly. |
…ystaple/mimir into 3437-alertmanager-config-validation
Ok - committed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! I left few minor comments before merging. Thanks!
CHANGELOG.md
Outdated
@@ -97,6 +97,7 @@ | |||
|
|||
### Mimirtool | |||
|
|||
* [ENHANCEMENT] Added `mimirtool alertmanager verify` command to validate configuration without uploading. #3247 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] I think you can proudly call it a new feature ;) We're also used to reference the PR number, so #3440 in this case.
* [ENHANCEMENT] Added `mimirtool alertmanager verify` command to validate configuration without uploading. #3247 | |
* [FEATURE] Added `mimirtool alertmanager verify` command to validate configuration without uploading. #3440 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. :)
@@ -92,6 +92,14 @@ mimirtool alertmanager load <config_file> | |||
mimirtool alertmanager load <config_file> <template_files>... | |||
``` | |||
|
|||
### Validate Alertmanager configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ##### Example
below is related to "Load Alertmanager configuration". I think you should:
- Move
### Validate Alertmanager configuration
after the example below (right before#### Delete Alertmanager configuration
) - Change
### Validate Alertmanager configuration
to#### Validate Alertmanager configuration
(4 hashes) to keep formatting consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Done.
pkg/mimirtool/commands/alerts.go
Outdated
getAlertsCmd.Flag("address", "Address of the Grafana Mimir cluster; alternatively, set "+envVars.Address+".").Envar(envVars.Address).Required().StringVar(&a.ClientConfig.Address) | ||
getAlertsCmd.Flag("id", "Grafana Mimir tenant ID; alternatively, set "+envVars.TenantID+".").Envar(envVars.TenantID).Required().StringVar(&a.ClientConfig.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Since there's a bit of repetition here between getAlertsCmd
, deleteCmd
and loadalertCmd
, what if we register these flags in a for loop, something like (pseudocode):
for _, cmd := range []*kingpin.CmdClause{getAlertsCmd, deleteCmd, loadalertCmd } {
cmd.Flag("address", ...)
cmd.Flag("id", ...)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that - more DRY. Done.
pkg/mimirtool/commands/alerts.go
Outdated
@@ -104,27 +113,39 @@ func (a *AlertmanagerCommand) getConfig(k *kingpin.ParseContext) error { | |||
return p.PrintAlertmanagerConfig(cfg, templates) | |||
} | |||
|
|||
func (a *AlertmanagerCommand) loadConfig(k *kingpin.ParseContext) error { | |||
func (a *AlertmanagerCommand) prepareAlertManagerConfig(k *kingpin.ParseContext) (error, string, map[string]string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] WDYT about calling it "read"? We're basically reading it from file.
func (a *AlertmanagerCommand) prepareAlertManagerConfig(k *kingpin.ParseContext) (error, string, map[string]string) { | |
func (a *AlertmanagerCommand) readAlertmanagerConfigFromFile(k *kingpin.ParseContext) (error, string, map[string]string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. And done.
Co-authored-by: Marco Pracucci <marco@pracucci.com>
Bump from enhancement to feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (modulo a nit). Thanks!
pkg/mimirtool/commands/alerts.go
Outdated
cmd.Flag("id", "Grafana Mimir tenant ID; alternatively, set "+envVars.TenantID+".").Envar(envVars.TenantID).Required().StringVar(&a.ClientConfig.ID) | ||
} | ||
|
||
vertifyalertCmd := alertCmd.Command("verify", "Verify Alertmanager tenant configuration and template files.").Action(a.verifyAlertmanagerConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Doh, there's a small typo here:
vertifyalertCmd := alertCmd.Command("verify", "Verify Alertmanager tenant configuration and template files.").Action(a.verifyAlertmanagerConfig) | |
verifyalertCmd := alertCmd.Command("verify", "Verify Alertmanager tenant configuration and template files.").Action(a.verifyAlertmanagerConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok - fixed.
Head branch was pushed to by a user without write access
Co-authored-by: Marco Pracucci <marco@pracucci.com> Add scheme to DNS service discovery docs (grafana#3450) * Add schema to DNS service discovery docs The missing schema leads to errors like `improperly formatted alertmanager URL "alertmanager.mimir.svc.cluster.local:8080/alertmanager" (maybe the scheme is missing?)`. * Update docs/sources/operators-guide/configure/about-dns-service-discovery.md Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Co-authored-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Alertmanager configuration validate-only mode grafana#3437 (grafana#3440) * Alertmanager configuration validate-only mode grafana#3437 * Documentation update for alertmanager config validation * Update changelog * Update docs/sources/operators-guide/architecture/components/alertmanager.md Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> * Swap a command line flag for a verify subcommand. * Update pkg/mimirtool/commands/alerts.go Co-authored-by: Marco Pracucci <marco@pracucci.com> * For loop to reduce repetition * Use review suggestion. * Make alertmanager verification docs more consistent. Bump from enhancement to feature. * fmt * Fix the golint issue. * Fix typo * Make doc result (as specified by lint process) Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Co-authored-by: Marco Pracucci <marco@pracucci.com> lint fix
* add runbook urls for alerts Co-authored-by: Joshua Hesketh <josh@hesketh.net.au> Update CHANGELOG.md Co-authored-by: Joshua Hesketh <josh@hesketh.net.au> * Update CHANGELOG.md Co-authored-by: Marco Pracucci <marco@pracucci.com> Add scheme to DNS service discovery docs (#3450) * Add schema to DNS service discovery docs The missing schema leads to errors like `improperly formatted alertmanager URL "alertmanager.mimir.svc.cluster.local:8080/alertmanager" (maybe the scheme is missing?)`. * Update docs/sources/operators-guide/configure/about-dns-service-discovery.md Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Co-authored-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Alertmanager configuration validate-only mode #3437 (#3440) * Alertmanager configuration validate-only mode #3437 * Documentation update for alertmanager config validation * Update changelog * Update docs/sources/operators-guide/architecture/components/alertmanager.md Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> * Swap a command line flag for a verify subcommand. * Update pkg/mimirtool/commands/alerts.go Co-authored-by: Marco Pracucci <marco@pracucci.com> * For loop to reduce repetition * Use review suggestion. * Make alertmanager verification docs more consistent. Bump from enhancement to feature. * fmt * Fix the golint issue. * Fix typo * Make doc result (as specified by lint process) Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Co-authored-by: Marco Pracucci <marco@pracucci.com> lint fix Co-authored-by: Joshua Hesketh <josh@hesketh.net.au>
) * Alertmanager configuration validate-only mode grafana#3437 * Documentation update for alertmanager config validation * Update changelog * Update docs/sources/operators-guide/architecture/components/alertmanager.md Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> * Swap a command line flag for a verify subcommand. * Update pkg/mimirtool/commands/alerts.go Co-authored-by: Marco Pracucci <marco@pracucci.com> * For loop to reduce repetition * Use review suggestion. * Make alertmanager verification docs more consistent. Bump from enhancement to feature. * fmt * Fix the golint issue. * Fix typo * Make doc result (as specified by lint process) Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Co-authored-by: Marco Pracucci <marco@pracucci.com>
* add runbook urls for alerts Co-authored-by: Joshua Hesketh <josh@hesketh.net.au> Update CHANGELOG.md Co-authored-by: Joshua Hesketh <josh@hesketh.net.au> * Update CHANGELOG.md Co-authored-by: Marco Pracucci <marco@pracucci.com> Add scheme to DNS service discovery docs (grafana#3450) * Add schema to DNS service discovery docs The missing schema leads to errors like `improperly formatted alertmanager URL "alertmanager.mimir.svc.cluster.local:8080/alertmanager" (maybe the scheme is missing?)`. * Update docs/sources/operators-guide/configure/about-dns-service-discovery.md Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Co-authored-by: Marco Pracucci <marco@pracucci.com> Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Alertmanager configuration validate-only mode grafana#3437 (grafana#3440) * Alertmanager configuration validate-only mode grafana#3437 * Documentation update for alertmanager config validation * Update changelog * Update docs/sources/operators-guide/architecture/components/alertmanager.md Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> * Swap a command line flag for a verify subcommand. * Update pkg/mimirtool/commands/alerts.go Co-authored-by: Marco Pracucci <marco@pracucci.com> * For loop to reduce repetition * Use review suggestion. * Make alertmanager verification docs more consistent. Bump from enhancement to feature. * fmt * Fix the golint issue. * Fix typo * Make doc result (as specified by lint process) Co-authored-by: Ursula Kallio <ursula.kallio@grafana.com> Co-authored-by: Marco Pracucci <marco@pracucci.com> lint fix Co-authored-by: Joshua Hesketh <josh@hesketh.net.au>
What this PR does
This introduces an additional flag for
mimirtool alertmanager load
to validate configuration only, without proceeding to upload it to server. This can be used to validate configuration, for example in PR CI pipelines before attempting to merge and deploy.Which issue(s) this PR fixes or relates to
Fixes #3437
Checklist
mimirtool alertmanager load
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]