Skip to content

Commit 429ea49

Browse files
author
Felix Breidenstein
committed
Fix wording (reciver->address) and add address field to message
1 parent 09c86d5 commit 429ea49

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

alamos/alamos.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type AlamosMessage struct {
1212
Message string `json:"message"`
1313
Type string `json:"type"`
1414
Sender string `json:"sender"`
15+
Address string `json:"address"`
1516
Timestamp int64 `json:"timestamp"`
1617
Data map[string]string `json:"data"`
1718
}
@@ -37,9 +38,11 @@ func makeTimestamp() int64 {
3738
func (c *AlamosClient) newAlamosMessage() AlamosMessage {
3839
m := AlamosMessage{
3940
Timestamp: makeTimestamp(),
41+
Sender: c.Sender,
42+
Address: c.Address,
4043
}
4144
if c.Test {
42-
m.Type = "Test"
45+
m.Type = "TEST"
4346
} else {
4447
m.Type = "ALARM"
4548
}
@@ -59,7 +62,6 @@ func NewClient(host string, sender string, address string, test bool) AlamosClie
5962

6063
func (client *AlamosClient) SendAlert(alertMessage string) error {
6164
message := client.newAlamosMessage()
62-
message.Sender = client.Sender
6365
message.Message = alertMessage
6466

6567
body, err := json.Marshal(message)

config_example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ debug: True
55

66
alamos_host: "localhost"
77
alamos_sender: "prometheus-gateway"
8-
alamos_receiver: "admingroup42"
8+
alamos_address: "admingroup42"

main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
type config struct {
2020
AlamosHost string `yaml:"alamos_host"`
2121
Sender string `yaml:"alamos_sender"`
22-
Receiver string `yaml:"alamos_receiver"`
22+
Address string `yaml:"alamos_address"`
2323
Debug bool `yaml:"debug"`
2424
Listen string `yaml:"listen"`
2525
}
@@ -77,7 +77,7 @@ func inputHandler(client *alamos.AlamosClient, debug bool) http.Handler {
7777
}
7878

7979
default:
80-
log.Printf("no action on severity: %s", severity)
80+
fmt.Printf("no action on severity: %s", severity)
8181
}
8282

8383
}
@@ -112,7 +112,9 @@ func main() {
112112
flag.Parse()
113113

114114
cfg := readConfigFile()
115-
client := alamos.NewClient(cfg.AlamosHost, cfg.Sender, cfg.Receiver, cfg.Debug)
115+
client := alamos.NewClient(cfg.AlamosHost, cfg.Sender, cfg.Address, cfg.Debug)
116+
117+
fmt.Printf("Alamos Client: %+v\n", client)
116118

117119
http.Handle("/input", inputHandler(&client, cfg.Debug))
118120

0 commit comments

Comments
 (0)