tech(pagerduty): declare url as constant

This commit is contained in:
bergquist 2016-11-08 07:50:58 +01:00
parent 6dd076efc1
commit 7bc80d0374

View File

@ -13,6 +13,10 @@ func init() {
alerting.RegisterNotifier("pagerduty", NewPagerdutyNotifier)
}
var (
pagerdutyEventApiUrl string = "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
)
func NewPagerdutyNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
key := model.Settings.Get("integrationKey").MustString()
if key == "" {
@ -37,10 +41,6 @@ func (this *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
metrics.M_Alerting_Notification_Sent_PagerDuty.Inc(1)
if evalContext.Rule.State == m.AlertStateAlerting {
// Pagerduty Events API URL
pgEventsUrl := "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
bodyJSON := simplejson.New()
bodyJSON.Set("service_key", this.Key)
bodyJSON.Set("description", evalContext.Rule.Name+" - "+evalContext.Rule.Message)
@ -66,7 +66,7 @@ func (this *PagerdutyNotifier) Notify(evalContext *alerting.EvalContext) error {
body, _ := bodyJSON.MarshalJSON()
cmd := &m.SendWebhook{
Url: pgEventsUrl,
Url: pagerdutyEventApiUrl,
Body: string(body),
HttpMethod: "POST",
}