-
Notifications
You must be signed in to change notification settings - Fork 543
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
Use grafana configuration in the Alertmanager #8066
Conversation
5d3c136
to
38a3fb3
Compare
…nandezc/use_grafana_receivers
…nandezc/use_grafana_receivers
…nandezc/use_grafana_receivers
…nandezc/use_grafana_receivers
…nd use helper functions, reduce diff
…nandezc/use_grafana_receivers
…nandezc/use_grafana_receivers
…nandezc/use_grafana_receivers
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 - Just some minor nits to clean up.
pkg/alertmanager/multitenant.go
Outdated
// Both configurations. | ||
// TODO: merge configurations. | ||
default: | ||
level.Debug(am.logger).Log("msg", "merging configurations not implemented, using mimir config", "user", cfgs.Mimir.User) |
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 think this should be at least warning, if not error.
level.Debug(am.logger).Log("msg", "merging configurations not implemented, using mimir config", "user", cfgs.Mimir.User) | |
level.Warn(am.logger).Log("msg", "merging configurations not implemented, using mimir config", "user", cfgs.Mimir.User) |
pkg/alertmanager/multitenant.go
Outdated
level.Debug(am.logger).Log("msg", "grafana configuration is empty, using mimir config", "user", cfgs.Mimir.User) | ||
cfg = cfgs.Mimir | ||
|
||
// Grafana 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.
// Grafana configuration. | |
// Grafana configuration. |
pkg/alertmanager/alertmanager.go
Outdated
// The decrypt functions and the context are used to decrypt the configuration. | ||
// We don't need to decrypt anything, so we can pass a no-op decrypt func and a context.Background(). | ||
rCfg, err := alertingNotify.BuildReceiverConfiguration(context.Background(), definition.PostableAPIReceiverToAPIReceiver(rcv), alertingNotify.NoopDecrypt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
integrations, err := alertingNotify.BuildReceiverIntegrations( | ||
rCfg, | ||
tmpl, | ||
&images.UnavailableProvider{}, // TODO: include images in notifications | ||
loggerFactory, | ||
whFn, | ||
emailFn, | ||
1, // orgID is always 1. | ||
version.Version, | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// TODO: use the nfstatus.Integration wrapper for all integrations. | ||
upstreamIntegrations := make([]*notify.Integration, 0, len(integrations)) | ||
for _, integration := range integrations { | ||
upstreamIntegrations = append(upstreamIntegrations, integration.Integration()) | ||
} |
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.
This would be nice pulled out into a function, e.g. buildGrafanaReceiverIntegrations
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.
Thanks for addressing the comments, LGTM
Description
This PR enables the Alertmanager to use the Grafana configuration, including Grafana receivers.
If the Grafana compatibility option is enabled, Mimir will look for Grafana Alertmanager configuration in object storage.
To be used, the Grafana configuration should be promoted, non-default, and non-empty. Otherwise, it will be ignored and only the Mimir AM configuration will be used.
If the Grafana configuration is promoted, non-default, and non-empty, and the Mimir AM configuration is either default or empty, only the Grafana configuration will be used.
If both configurations are neither default nor empty and the Grafana configuration is promoted, both configurations will be merged and the resulting configuration will be applied to the Alertmanager. This scenario is outside of the scope of this PR.