mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
d4ac4b7813
vmalert: support option to blackhole alerting notifications https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4122 --------- Co-authored-by: Rao, B V Chalapathi <b_v_chalapathi.rao@nokia.com>
35 lines
880 B
Go
35 lines
880 B
Go
package notifier
|
|
|
|
import "context"
|
|
|
|
// BlackHoleNotifier is used when no notifications needs to be sent
|
|
type BlackHoleNotifier struct {
|
|
addr string
|
|
metrics *metrics
|
|
}
|
|
|
|
// Send will not send any notifications. Only increase the alerts sent number.
|
|
func (bh *BlackHoleNotifier) Send(_ context.Context, alerts []Alert, _ map[string]string) error { //nolint:revive
|
|
bh.metrics.alertsSent.Add(len(alerts))
|
|
return nil
|
|
}
|
|
|
|
// Addr of black hole notifier
|
|
func (bh BlackHoleNotifier) Addr() string {
|
|
return bh.addr
|
|
}
|
|
|
|
// Close unregister the metrics
|
|
func (bh *BlackHoleNotifier) Close() {
|
|
bh.metrics.alertsSent.Unregister()
|
|
bh.metrics.alertsSendErrors.Unregister()
|
|
}
|
|
|
|
// NewBlackHoleNotifier Create a new BlackHoleNotifier
|
|
func NewBlackHoleNotifier() *BlackHoleNotifier {
|
|
address := "blackhole"
|
|
return &BlackHoleNotifier{
|
|
addr: address,
|
|
metrics: newMetrics(address),
|
|
}
|
|
}
|