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

Update Alertmanager via grafana/alertmanager-prometheus to the latest main #44

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions alerting/grafana_alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ type NotifyReceiver = notify.Receiver
// Configuration is an interface for accessing Alertmanager configuration.
type Configuration interface {
DispatcherLimits() DispatcherLimits
InhibitRules() []*InhibitRule
InhibitRules() []InhibitRule
MuteTimeIntervals() []MuteTimeInterval
ReceiverIntegrations() (map[string][]*Integration, error)
BuildReceiverIntegrationsFunc() func(next *GrafanaReceiver, tmpl *Template) (Notifier, error)
Expand Down Expand Up @@ -203,15 +203,12 @@ func NewGrafanaAlertmanager(tenantKey string, tenantID int64, config *GrafanaAle
}

// Initialize the notification log
am.wg.Add(1)
am.notificationLog, err = nflog.New(
nflog.WithRetention(config.Nflog.Retention()),
nflog.WithSnapshot(config.Nflog.Filepath()),
nflog.WithMaintenance(config.Nflog.MaintenanceFrequency(), am.stopc, am.wg.Done, func() (int64, error) {
//TODO: There's a bug here, we need to call GC to ensure we cleanup old entries: https://github.com/grafana/alerting/issues/3
return config.Nflog.MaintenanceFunc(am.silences) // this is wrong, we need the notification log.
}),
)
am.notificationLog, err = nflog.New(nflog.Options{
SnapshotFile: config.Nflog.Filepath(),
Retention: config.Nflog.Retention(),
Logger: logger,
})

if err != nil {
return nil, fmt.Errorf("unable to initialize the notification log component of alerting: %w", err)
}
Expand All @@ -221,6 +218,18 @@ func NewGrafanaAlertmanager(tenantKey string, tenantID int64, config *GrafanaAle
c = am.peer.AddState(fmt.Sprintf("silences:%d", am.tenantID), am.silences, m.Registerer)
am.silences.SetBroadcast(c.Broadcast)

am.wg.Add(1)
go func() {
am.notificationLog.Maintenance(config.Nflog.MaintenanceFrequency(), config.Silences.Filepath(), am.stopc, func() (int64, error) {
if _, err := am.notificationLog.GC(); err != nil {
level.Error(am.logger).Log("notification log garbage collection", "err", err)
}

return config.Nflog.MaintenanceFunc(am.silences)
})
am.wg.Done()
}()

am.wg.Add(1)
go func() {
am.silences.Maintenance(config.Silences.MaintenanceFrequency(), config.Silences.Filepath(), am.stopc, func() (int64, error) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/prometheus/alertmanager => github.com/grafana/prometheus-alertmanager v0.25.1-0.20230109182643-002d8ba820f6
replace github.com/prometheus/alertmanager => github.com/grafana/prometheus-alertmanager v0.25.1-0.20230119183635-ec19b0a443b7

replace github.com/Unknwon/com v1.0.1 => github.com/unknwon/com v1.0.1

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/grafana/prometheus-alertmanager v0.25.1-0.20230109182643-002d8ba820f6 h1:teookZDfQHNJWhsXujYZLhIeLFWzZZtqeqqfkQwOcLI=
github.com/grafana/prometheus-alertmanager v0.25.1-0.20230109182643-002d8ba820f6/go.mod h1:MnBfDPXJqXmmfPwQlCLvVUdqfnvrAw+hSPtDeaaFwj4=
github.com/grafana/prometheus-alertmanager v0.25.1-0.20230119183635-ec19b0a443b7 h1:ma1CfisUaAXQzL24tCao9yMleZYsFJ853m2l0rgahyE=
github.com/grafana/prometheus-alertmanager v0.25.1-0.20230119183635-ec19b0a443b7/go.mod h1:MnBfDPXJqXmmfPwQlCLvVUdqfnvrAw+hSPtDeaaFwj4=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down