-
Notifications
You must be signed in to change notification settings - Fork 537
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: Use the default email sender for Grafana receivers #8529
Alertmanager: Use the default email sender for Grafana receivers #8529
Conversation
Just a heads up that the build and tests will fail until #8525 is merged to main and you can rebase. I'm working to get a second review of it as soon as possible.
|
Hi! 👋 You can rebase main as #8525 is closed. This will fix the build failure and tests 👍 |
…nandezc/use_default_email_sender
…nandezc/use_default_email_sender
…nandezc/use_default_email_sender
pkg/alertmanager/config.go
Outdated
"github.com/grafana/mimir/pkg/alertmanager/alertspb" | ||
) | ||
|
||
// parseGrafanaConfig creates an AlertConfigDesc from a GrafanaAlertConfigDesc. | ||
func parseGrafanaConfig(cfg alertspb.GrafanaAlertConfigDesc) (alertspb.AlertConfigDesc, error) { | ||
// It uses the global section from the Mimir config if it is provided. | ||
func parseGrafanaConfig(gCfg alertspb.GrafanaAlertConfigDesc, mCfg *alertspb.AlertConfigDesc) (alertspb.AlertConfigDesc, error) { |
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 don't think parseGrafanaConfig
is a suitable name anymore, something like parseConfig
might be more appropriate?
pkg/alertmanager/multitenant.go
Outdated
@@ -708,14 +708,14 @@ func (am *MultitenantAlertmanager) computeConfig(cfgs alertspb.AlertConfigDescs) | |||
// Grafana configuration. | |||
case cfgs.Mimir.RawConfig == am.fallbackConfig: | |||
level.Debug(am.logger).Log("msg", "mimir configuration is default, using grafana config", "user", cfgs.Mimir.User) | |||
cfg, err = parseGrafanaConfig(cfgs.Grafana) | |||
cfg, err = parseGrafanaConfig(cfgs.Grafana, &cfgs.Mimir) |
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'd also update the log message above
pkg/alertmanager/multitenant_test.go
Outdated
@@ -394,7 +395,7 @@ templates: | |||
require.Len(t, am.alertmanagers, 4) | |||
|
|||
// The Mimir configuration was empty, so the Grafana configuration should be chosen for user 4. | |||
parsed, err := parseGrafanaConfig(userGrafanaCfg) | |||
parsed, err := parseGrafanaConfig(userGrafanaCfg, nil) |
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 know this isn't directly to do with this PR, but just a code quality change:
require.NoError(t, store.SetAlertConfig(ctx, emptyMimirConfig))
can be done on line 391 above.
pkg/alertmanager/multitenant_test.go
Outdated
}, | ||
expCfg: alertspb.AlertConfigDesc{ | ||
User: "user", | ||
RawConfig: string(simpleConfigOne), |
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.
simpleConfigOne
doesn't need to be casted to string
…fana#8529) * Alertmanager: Use the default email sender for Grafana receivers * tests, fix mimir global config not being used in Grafana * address code review comments * format
This PR updates the Alertmanager to use the default email sender from grafana/alerting for sending notifications with Grafana's email integration.
If the Grafana Alertmanager configuration is to be used, we use the SMTP and HTTP settings from the
global
section of Mimir's Alertmanager configuration to configure the email sender.Related PoC: #8376