mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added trigger options with Pagerduty
This commit is contained in:
parent
139bbecc10
commit
df8cd764b2
@ -19,24 +19,44 @@ func NewPagerdutyNotifier(model *m.AlertNotification) (alerting.Notifier, error)
|
|||||||
return nil, alerting.ValidationError{Reason: "Could not find integration key property in settings"}
|
return nil, alerting.ValidationError{Reason: "Could not find integration key property in settings"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alertingStates := make([]m.AlertStateType, 0)
|
||||||
|
alertingStates = append(alertingStates, m.AlertStateAlerting)
|
||||||
|
if model.Settings.Get("alertOnExecError").MustBool() {
|
||||||
|
alertingStates = append(alertingStates, m.AlertStateExecError)
|
||||||
|
}
|
||||||
|
if model.Settings.Get("alertOnNoData").MustBool() {
|
||||||
|
alertingStates = append(alertingStates, m.AlertStateNoData)
|
||||||
|
}
|
||||||
|
|
||||||
return &PagerdutyNotifier{
|
return &PagerdutyNotifier{
|
||||||
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
|
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
|
||||||
Key: key,
|
Key: key,
|
||||||
log: log.New("alerting.notifier.pagerduty"),
|
AlertingStates: alertingStates,
|
||||||
|
log: log.New("alerting.notifier.pagerduty"),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type PagerdutyNotifier struct {
|
type PagerdutyNotifier struct {
|
||||||
NotifierBase
|
NotifierBase
|
||||||
Key string
|
Key string
|
||||||
log log.Logger
|
AlertingStates []m.AlertStateType
|
||||||
|
log log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
|
func (this *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||||
this.log.Info("Notifying Pagerduty")
|
this.log.Info("Notifying Pagerduty")
|
||||||
metrics.M_Alerting_Notification_Sent_PagerDuty.Inc(1)
|
metrics.M_Alerting_Notification_Sent_PagerDuty.Inc(1)
|
||||||
|
|
||||||
if evalContext.Rule.State == m.AlertStateAlerting {
|
shouldNotify := false
|
||||||
|
|
||||||
|
for _, state := range this.AlertingStates {
|
||||||
|
if evalContext.Rule.State == state {
|
||||||
|
shouldNotify = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if shouldNotify {
|
||||||
|
|
||||||
// Pagerduty Events API URL
|
// Pagerduty Events API URL
|
||||||
pgEventsUrl := "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
|
pgEventsUrl := "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
|
||||||
|
@ -121,15 +121,6 @@
|
|||||||
tooltip="Trigger incident on Execution Error">
|
tooltip="Trigger incident on Execution Error">
|
||||||
</gf-form-switch>
|
</gf-form-switch>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form">
|
|
||||||
<gf-form-switch
|
|
||||||
class="gf-form"
|
|
||||||
label="Auto resolve on OK"
|
|
||||||
label-class="width-12"
|
|
||||||
checked="ctrl.model.settings.resolveOnOK"
|
|
||||||
tooltip="Resolve incident on OK">
|
|
||||||
</gf-form-switch>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="gf-form-group">
|
<div class="gf-form-group">
|
||||||
|
Loading…
Reference in New Issue
Block a user