mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-28 00:52:13 +00:00
Merge pull request #1151 from prometheus/stn/configurable-alert-gc
Make alertGC interval configurable
This commit is contained in:
commit
8b8642935a
@ -112,9 +112,10 @@ func main() {
|
||||
var (
|
||||
showVersion = flag.Bool("version", false, "Print version information.")
|
||||
|
||||
configFile = flag.String("config.file", "alertmanager.yml", "Alertmanager configuration file name.")
|
||||
dataDir = flag.String("storage.path", "data/", "Base path for data storage.")
|
||||
retention = flag.Duration("data.retention", 5*24*time.Hour, "How long to keep data for.")
|
||||
configFile = flag.String("config.file", "alertmanager.yml", "Alertmanager configuration file name.")
|
||||
dataDir = flag.String("storage.path", "data/", "Base path for data storage.")
|
||||
retention = flag.Duration("data.retention", 5*24*time.Hour, "How long to keep data for.")
|
||||
alertGCInterval = flag.Duration("alerts.gc-interval", 30*time.Minute, "Interval between alert GC.")
|
||||
|
||||
externalURL = flag.String("web.external-url", "", "The URL under which Alertmanager is externally reachable (for example, if Alertmanager is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Alertmanager. If omitted, relevant URL components will be derived automatically.")
|
||||
routePrefix = flag.String("web.route-prefix", "", "Prefix for the internal routes of web endpoints. Defaults to path of -web.external-url.")
|
||||
@ -245,7 +246,7 @@ func main() {
|
||||
wg.Wait()
|
||||
}()
|
||||
|
||||
alerts, err := mem.NewAlerts(marker, 30*time.Minute, *dataDir)
|
||||
alerts, err := mem.NewAlerts(marker, *alertGCInterval)
|
||||
if err != nil {
|
||||
level.Error(logger).Log("err", err)
|
||||
os.Exit(1)
|
||||
|
@ -35,7 +35,7 @@ type Alerts struct {
|
||||
}
|
||||
|
||||
// NewAlerts returns a new alert provider.
|
||||
func NewAlerts(m types.Marker, intervalGC time.Duration, path string) (*Alerts, error) {
|
||||
func NewAlerts(m types.Marker, intervalGC time.Duration) (*Alerts, error) {
|
||||
a := &Alerts{
|
||||
alerts: map[model.Fingerprint]*types.Alert{},
|
||||
marker: m,
|
||||
|
@ -14,8 +14,6 @@
|
||||
package mem
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
@ -31,13 +29,8 @@ func init() {
|
||||
}
|
||||
|
||||
func TestAlertsPut(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "alerts_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
marker := types.NewMarker()
|
||||
alerts, err := NewAlerts(marker, 30*time.Minute, dir)
|
||||
alerts, err := NewAlerts(marker, 30*time.Minute)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -98,14 +91,8 @@ func TestAlertsPut(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAlertsGC(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "alerts_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
marker := types.NewMarker()
|
||||
alerts, err := NewAlerts(marker, 200*time.Millisecond, dir)
|
||||
alerts, err := NewAlerts(marker, 200*time.Millisecond)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user