2021-03-18 13:12:28 -05:00
|
|
|
package models
|
|
|
|
|
2021-03-31 15:00:56 -05:00
|
|
|
const AlertConfigurationVersion = 1
|
|
|
|
|
2021-03-18 13:12:28 -05:00
|
|
|
// AlertConfiguration represents a single version of the Alerting Engine Configuration.
|
|
|
|
type AlertConfiguration struct {
|
|
|
|
ID int64 `xorm:"pk autoincr 'id'"`
|
|
|
|
|
|
|
|
AlertmanagerConfiguration string
|
2022-03-23 03:31:46 -05:00
|
|
|
ConfigurationHash string
|
2021-03-18 13:12:28 -05:00
|
|
|
ConfigurationVersion string
|
2021-06-04 07:52:41 -05:00
|
|
|
CreatedAt int64 `xorm:"created"`
|
2021-05-14 13:49:54 -05:00
|
|
|
Default bool
|
2021-08-12 08:04:09 -05:00
|
|
|
OrgID int64 `xorm:"org_id"`
|
2021-03-18 13:12:28 -05:00
|
|
|
}
|
|
|
|
|
2023-02-02 11:45:17 -06:00
|
|
|
// HistoricAlertConfiguration represents a previously used alerting configuration.
|
|
|
|
type HistoricAlertConfiguration struct {
|
2023-03-31 15:43:04 -05:00
|
|
|
ID int64 `xorm:"pk autoincr 'id'"`
|
2023-02-02 11:45:17 -06:00
|
|
|
AlertConfiguration `xorm:"extends"`
|
|
|
|
|
|
|
|
// LastApplied a timestamp indicating the most recent time at which the configuration was applied to an Alertmanager, or 0 otherwise.
|
|
|
|
// Only set this field if the configuration has been applied by the caller.
|
|
|
|
LastApplied int64 `xorm:"last_applied"`
|
|
|
|
}
|
|
|
|
|
2021-03-31 15:00:56 -05:00
|
|
|
// SaveAlertmanagerConfigurationCmd is the command to save an alertmanager configuration.
|
|
|
|
type SaveAlertmanagerConfigurationCmd struct {
|
|
|
|
AlertmanagerConfiguration string
|
2022-03-23 03:31:46 -05:00
|
|
|
FetchedConfigurationHash string
|
2021-03-31 15:00:56 -05:00
|
|
|
ConfigurationVersion string
|
2021-05-14 13:49:54 -05:00
|
|
|
Default bool
|
2021-08-12 08:04:09 -05:00
|
|
|
OrgID int64
|
2023-02-02 11:45:17 -06:00
|
|
|
LastApplied int64
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarkConfigurationAsAppliedCmd is the command for marking a previously saved configuration as successfully applied.
|
|
|
|
type MarkConfigurationAsAppliedCmd struct {
|
|
|
|
OrgID int64
|
|
|
|
ConfigurationHash string
|
|
|
|
}
|
|
|
|
|
|
|
|
func HistoricConfigFromAlertConfig(config AlertConfiguration) HistoricAlertConfiguration {
|
2023-03-31 15:43:04 -05:00
|
|
|
// Reset the ID so it can be generated by the DB.
|
2023-02-02 11:45:17 -06:00
|
|
|
config.ID = 0
|
|
|
|
return HistoricAlertConfiguration{
|
|
|
|
AlertConfiguration: config,
|
|
|
|
}
|
2021-03-31 15:00:56 -05:00
|
|
|
}
|