Skip to content

Commit

Permalink
minor fixes and typo
Browse files Browse the repository at this point in the history
  • Loading branch information
83bytes committed Jul 1, 2024
1 parent dfa13d8 commit b26239b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions alert/processAlert.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ func ProcessAlert(a types.Alert) {
actionMap := action.GetActionMap()

// these are used to capture the result of the enrichments
var err error
resMap := make(map[string]interface{}, len(p.Enrichments))

// process enrichments
for _, v := range (*p).Enrichments {
logr.Info("processing enrichment : ", v.EnrichmentName)

if f, ok := (*enrichmentMap)[v.EnrichmentName]; ok {
resMap[v.StepName], err = f(a, v)
tt, err := f(a, v)
if err != nil {
fmt.Println(err)
logr.Error("error from processing function")
}
resMap[v.StepName] = tt
} else {
logr.Info("no enrichment found with name: ", v.EnrichmentName)
}
Expand All @@ -75,7 +75,7 @@ func ProcessAlert(a types.Alert) {
if f, ok := (*actionMap)[v.ActionName]; ok {
err := f(a, v, resMap)
if err != nil {
fmt.Println(err)
logr.Error("error processing action:", err)
}
} else {
logr.Info("no action found with name: ", v.ActionName)
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.5"
services:
toy_alert_manager:
container_name: toy_alert_manager
image: tam:0.0.1
image: alertmanager:0.0.1
restart: always
network_mode: host
ulimits:
Expand All @@ -11,10 +11,10 @@ services:
soft: 1000000
hard: 1000000
volumes:
- ./alert-manager-config-2.yml:/alert-manager-config-2.yml
- ./alert-manager-config.yml:/alert-manager-config.yml
command:
- server
- --config-file
- "./alert-manager-config-2.yml"
- "./alert-manager-config.yml"
- --log-level
- DEBUG
5 changes: 4 additions & 1 deletion enrichment/getPromQlEnrichment.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func GetPromQLEnrichment(alert types.Alert, e types.Enrichment) (interface{}, er
if err != nil {
return nil, fmt.Errorf("error unmarshaling JSON: %v", err)
}

// check if result is empty
if len(pres.Data.Result) <= 0 {
return "", nil
}
return fmt.Sprint(pres.Data.Result[0].Value[1]), nil
}

0 comments on commit b26239b

Please sign in to comment.