2021-03-08 14:19:21 -06:00
|
|
|
package store
|
2020-11-12 07:11:30 -06:00
|
|
|
|
|
|
|
import (
|
2021-03-03 09:52:19 -06:00
|
|
|
"time"
|
2020-11-12 07:11:30 -06:00
|
|
|
|
2021-03-08 14:19:21 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
|
|
|
|
2020-11-12 07:11:30 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/sqlstore"
|
|
|
|
)
|
|
|
|
|
2021-03-08 14:19:21 -06:00
|
|
|
// TimeNow makes it possible to test usage of time
|
|
|
|
var TimeNow = time.Now
|
|
|
|
|
2021-04-01 03:11:45 -05:00
|
|
|
// AlertDefinitionMaxTitleLength is the maximum length of the alert definition title
|
2021-03-08 14:19:21 -06:00
|
|
|
const AlertDefinitionMaxTitleLength = 190
|
|
|
|
|
2021-03-24 09:20:44 -05:00
|
|
|
// AlertingStore is the database interface used by the Alertmanager service.
|
|
|
|
type AlertingStore interface {
|
2021-03-31 15:00:56 -05:00
|
|
|
GetLatestAlertmanagerConfiguration(*models.GetLatestAlertmanagerConfigurationQuery) error
|
|
|
|
GetAlertmanagerConfiguration(*models.GetAlertmanagerConfigurationQuery) error
|
|
|
|
SaveAlertmanagerConfiguration(*models.SaveAlertmanagerConfigurationCmd) error
|
2021-03-03 09:52:19 -06:00
|
|
|
}
|
|
|
|
|
2021-03-08 14:19:21 -06:00
|
|
|
// DBstore stores the alert definitions and instances in the database.
|
|
|
|
type DBstore struct {
|
2021-03-03 09:52:19 -06:00
|
|
|
// the base scheduler tick rate; it's used for validating definition interval
|
2021-03-08 14:19:21 -06:00
|
|
|
BaseInterval time.Duration
|
|
|
|
// default alert definiiton interval
|
|
|
|
DefaultIntervalSeconds int64
|
|
|
|
SQLStore *sqlstore.SQLStore `inject:""`
|
2021-03-03 09:52:19 -06:00
|
|
|
}
|