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

Refactor GrafanaAlertmanager to not depend on Grafana #19

Merged
merged 10 commits into from
Nov 23, 2022

Conversation

gotjosh
Copy link
Collaborator

@gotjosh gotjosh commented Nov 2, 2022

This is the first substantial PR at decoupling the Alertmanager logic from the Grafana-specific logic - you can reference that by the removal of the Grafana-based imports from the code and the scope of an interface for that specific logic.

There's a LOT more work TODO (hence the number of comments in the code), but these should be followed up immediately and are very obvious that things don't work. For the ones that we think would be more long term and I'm happy to create an issue to track them.

@gotjosh gotjosh marked this pull request as ready for review November 2, 2022 18:22
type Notifier = notify.Notifier

// Configuration is an interface for accessing Alertmanager configuration.
type Configuration interface {
Copy link
Collaborator Author

@gotjosh gotjosh Nov 2, 2022

Choose a reason for hiding this comment

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

This is the biggest piece of this work - we've abstracted everything that could be Grafana-specific in an interface, there's probably more than will either go to Grafana or come back here but I've tried to do the minimum for now to get something done.

@@ -135,7 +112,32 @@ type MaintenanceOptions interface {
MaintenanceFunc() (int64, error)
}

type Template = template.Template
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -21,11 +22,17 @@ var (
ErrGetAlertGroupsBadPayload = fmt.Errorf("unable to retrieve alerts groups")
)

func (am *GrafanaAlertmanager) GetAlerts(active, silenced, inhibited bool, filter []string, receivers string) (apimodels.GettableAlerts, error) {
type GettableAlerts = amv2.GettableAlerts
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There will be a better place to organise this, but for now, I want to make the diffs minimal until we know for sure that this works for Grafana. Then we can refactor away at our liking.

Copy link
Contributor

@yuri-tceretian yuri-tceretian left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@JohnnyQQQQ JohnnyQQQQ left a comment

Choose a reason for hiding this comment

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

LGTM, let's go!

@gotjosh gotjosh enabled auto-merge (squash) November 23, 2022 21:53
@gotjosh gotjosh merged commit 67a9f44 into main Nov 23, 2022
@gotjosh gotjosh deleted the grafana-alertmanager-not-depend-on-grafana branch November 23, 2022 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants