From 74d77dcda9178f511be469c69cb020a10026e042 Mon Sep 17 00:00:00 2001 From: Andy Tien Date: Thu, 20 Dec 2018 12:56:48 -0500 Subject: [PATCH] revere: add configurable host into env Allows configuration of the host R=robfig,eefi TEST=manual --- daemon/subprobe.go | 1 + env/env.go | 3 +++ target/alert.go | 2 ++ target/emailtype.go | 3 +-- target/slacknotifier.go | 4 ++-- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/daemon/subprobe.go b/daemon/subprobe.go index 94d5c03..25a2da4 100644 --- a/daemon/subprobe.go +++ b/daemon/subprobe.go @@ -171,6 +171,7 @@ func (s *subprobe) newAlert(oldState state.State, r probe.Reading) *target.Alert LastNormal: s.lastNormal, Details: r.Details, + Host: s.Env.Host, } } diff --git a/env/env.go b/env/env.go index 6ad36e0..2b19e5e 100644 --- a/env/env.go +++ b/env/env.go @@ -15,6 +15,7 @@ import ( type Env struct { DB *db.DB Port uint16 + Host string } // New initializes an Env based on the configuration found in conf, which @@ -41,6 +42,7 @@ func New(conf []byte) (*Env, error) { return nil, errors.Maskf(err, "load DB") } e.Port = model.Port + e.Host = model.Host return &e, nil } @@ -50,4 +52,5 @@ func New(conf []byte) (*Env, error) { type EnvJSONModel struct { DB db.DBJSONModel Port uint16 + Host string } diff --git a/target/alert.go b/target/alert.go index bb2677e..c532516 100644 --- a/target/alert.go +++ b/target/alert.go @@ -26,4 +26,6 @@ type Alert struct { LastNormal time.Time Details probe.Details + + Host string } diff --git a/target/emailtype.go b/target/emailtype.go index df4e4d1..f71519f 100644 --- a/target/emailtype.go +++ b/target/emailtype.go @@ -116,11 +116,10 @@ func (_ emailType) Alert(Db *db.DB, a *Alert, toAlert map[db.TriggerID]Target, i return nil } -// TODO(eefi): Update Revere link. const emailText = ` {{.NewState}} is the state of {{.MonitorName}}/{{.SubprobeName}} as of {{time .Recorded}}. -http://revere.khan/monitors/{{.MonitorID}}/subprobes/{{.SubprobeID}} +{{.Host}}/monitors/{{.MonitorID}}/subprobes/{{.SubprobeID}} {{if ne .OldState .NewState -}} State change: {{.OldState}}->{{.NewState}} diff --git a/target/slacknotifier.go b/target/slacknotifier.go index 8a86778..5e4fcf3 100644 --- a/target/slacknotifier.go +++ b/target/slacknotifier.go @@ -107,8 +107,8 @@ func (s slackNotifier) formatMessage(channel string) (io.Reader, error) { Attachments: []attachment{ { Title: fmt.Sprintf("%s/%s", s.alert.MonitorName, s.alert.SubprobeName), - TitleLink: fmt.Sprintf("http://revere.khan/monitors/%d/subprobes/%d", - s.alert.MonitorID, s.alert.SubprobeID), + TitleLink: fmt.Sprintf("%s/monitors/%d/subprobes/%d", + s.alert.Host, s.alert.MonitorID, s.alert.SubprobeID), Fallback: fmt.Sprintf("%s/%s entered state: %s", s.alert.MonitorName, s.alert.SubprobeName, s.alert.NewState), Color: stateColors[s.alert.NewState],