The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/alerting/notifiers/base.go

53 lines
1.1 KiB

package notifiers
import (
"github.com/grafana/grafana/pkg/components/simplejson"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/alerting"
)
type NotifierBase struct {
Name string
Type string
Id int64
IsDeault bool
UploadImage bool
}
func NewNotifierBase(id int64, isDefault bool, name, notifierType string, model *simplejson.Json) NotifierBase {
uploadImage := model.Get("uploadImage").MustBool(false)
return NotifierBase{
Id: id,
Name: name,
IsDeault: isDefault,
Type: notifierType,
UploadImage: uploadImage,
}
}
func defaultShouldNotify(context *alerting.EvalContext) bool {
if context.PrevAlertState == context.Rule.State {
return false
}
if (context.PrevAlertState == m.AlertStatePending) && (context.Rule.State == m.AlertStateOK) {
return false
}
return true
}
func (n *NotifierBase) GetType() string {
return n.Type
}
func (n *NotifierBase) NeedsImage() bool {
return n.UploadImage
}
func (n *NotifierBase) GetNotifierId() int64 {
return n.Id
}
func (n *NotifierBase) GetIsDefault() bool {
return n.IsDeault
}