Skip to content

Commit 27ac28c

Browse files
committed
Set system on incoming alerts
1 parent 27695c6 commit 27ac28c

39 files changed

+9607
-963
lines changed

Gopkg.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/consume.go

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var group string
3838
var delay int
3939
var alertsAddress string
4040
var fetchTopic string
41+
var system string
4142

4243
// consumeCmd represents the consume command
4344
var consumeCmd = &cobra.Command{
@@ -65,6 +66,7 @@ var consumeCmd = &cobra.Command{
6566
Delay: delay,
6667
AlertsService: alertsService,
6768
FetchTopic: fetchTopic,
69+
System: system,
6870
}
6971

7072
ctx, cancel := context.WithCancel(context.Background())
@@ -102,4 +104,6 @@ func init() {
102104
consumeCmd.MarkFlagRequired("alerts-address")
103105

104106
consumeCmd.Flags().StringVarP(&fetchTopic, "fetch-topic", "f", "", "Fetch topic")
107+
108+
consumeCmd.Flags().StringVarP(&system, "system", "s", "naads", "System name")
105109
}

pkg/processor/alerts.go

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ func collectAlert(ctx context.Context, conf *Config) func(ctx goka.Context, msg
7272
// TODO: Handle
7373
}
7474

75+
// Add the system
76+
alert.System = conf.System
77+
7578
// Save the alert, if it's good
7679
if (alert.Status == cap.Alert_ACTUAL || alert.Status == cap.Alert_EXCERCISE || alert.Status == cap.Alert_TEST) && (alert.MessageType == cap.Alert_ALERT || alert.MessageType == cap.Alert_UPDATE || alert.MessageType == cap.Alert_CANCEL) {
7780
if _, err := conf.AlertsService.Add(ctx, &alert); err != nil {

pkg/processor/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ type Config struct {
1616
FetchTopic string
1717
AlertsTopic string
1818
FetchURLs []string
19+
20+
System string
1921
}

vendor/github.com/alerting/alerts/README.md

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/alerting/alerts/cmd/alerts/cmd/serve.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)