-
Notifications
You must be signed in to change notification settings - Fork 316
/
alertmanager.go
49 lines (42 loc) · 1.08 KB
/
alertmanager.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package alert
import (
"errors"
"github.com/rudderlabs/rudder-server/config"
"github.com/rudderlabs/rudder-server/utils/logger"
)
var (
alertProvider string
pagerDutyRoutingKey string
instanceName string
victorOpsRoutingKey string
)
func Init() {
loadConfig()
pkgLogger = logger.NewLogger().Child("alert")
}
func loadConfig() {
alertProvider = config.GetString("ALERT_PROVIDER", "victorops")
pagerDutyRoutingKey = config.GetString("PG_ROUTING_KEY", "")
instanceName = config.GetString("INSTANCE_ID", "")
victorOpsRoutingKey = config.GetString("VICTOROPS_ROUTING_KEY", "")
}
// AlertManager interface
type AlertManager interface {
Alert(string)
}
// New returns FileManager backed by configured privider
func New() (AlertManager, error) {
switch alertProvider {
case "victorops":
return &VictorOps{
routingKey: victorOpsRoutingKey,
instanceName: instanceName,
}, nil
case "pagerduty":
return &PagerDuty{
routingKey: pagerDutyRoutingKey,
instanceName: instanceName,
}, nil
}
return nil, errors.New("No provider configured for Alert Manager")
}