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

Use grafana configuration in the Alertmanager #8066

Merged
merged 24 commits into from
Jun 7, 2024

Conversation

santihernandezc
Copy link
Contributor

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.

@santihernandezc santihernandezc force-pushed the santihernandezc/use_grafana_receivers branch from 5d3c136 to 38a3fb3 Compare May 8, 2024 13:03
@santihernandezc santihernandezc marked this pull request as ready for review June 6, 2024 09:34
@santihernandezc santihernandezc requested review from grafanabot and a team as code owners June 6, 2024 09:34
@santihernandezc santihernandezc changed the title (WIP) Use grafana configuration in the Alertmanager Use grafana configuration in the Alertmanager Jun 6, 2024
@stevesg stevesg self-requested a review June 6, 2024 19:17
Copy link
Contributor

@stevesg stevesg left a 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.

// Both configurations.
// TODO: merge configurations.
default:
level.Debug(am.logger).Log("msg", "merging configurations not implemented, using mimir config", "user", cfgs.Mimir.User)
Copy link
Contributor

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.

Suggested change
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)

level.Debug(am.logger).Log("msg", "grafana configuration is empty, using mimir config", "user", cfgs.Mimir.User)
cfg = cfgs.Mimir

// Grafana configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Grafana configuration.
// Grafana configuration.

Comment on lines 476 to 501
// 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())
}
Copy link
Contributor

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

@santihernandezc santihernandezc requested a review from stevesg June 7, 2024 14:52
Copy link
Contributor

@stevesg stevesg left a 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

@santihernandezc santihernandezc merged commit b8e50f7 into main Jun 7, 2024
29 checks passed
@santihernandezc santihernandezc deleted the santihernandezc/use_grafana_receivers branch June 7, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants