diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index 8ac93cff..b1543b4d 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -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) diff --git a/provider/mem/mem.go b/provider/mem/mem.go index fc119f87..23c91e22 100644 --- a/provider/mem/mem.go +++ b/provider/mem/mem.go @@ -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, diff --git a/provider/mem/mem_test.go b/provider/mem/mem_test.go index ddc15d5c..5ad649ce 100644 --- a/provider/mem/mem_test.go +++ b/provider/mem/mem_test.go @@ -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) }