@@ -74,10 +74,7 @@ type AlertCorrelation struct {
7474}
7575
7676func GetRelatedAlerts () ([]schema.Alert , error ) {
77- // Debug log
78- utils .Logger .Info ("Getting historical alerts from Elasticsearch" )
79-
80- result , err := ElasticSearch (configurations .ALERT_INDEX_PATTERN , "*" , "*" )
77+ result , err := ElasticSearch (configurations .ALERT_INDEX_PATTERN , "" , "" )
8178 if err != nil {
8279 return nil , fmt .Errorf ("error getting historical alerts: %v" , err )
8380 }
@@ -92,9 +89,6 @@ func GetRelatedAlerts() ([]schema.Alert, error) {
9289}
9390
9491func FindRelatedAlerts (currentAlert schema.Alert ) (* AlertCorrelation , error ) {
95- // Debug log
96- utils .Logger .Info ("Finding related alerts for alert %s" , currentAlert .ID )
97-
9892 correlation := & AlertCorrelation {
9993 CurrentAlert : currentAlert ,
10094 RelatedAlerts : []schema.Alert {},
@@ -106,8 +100,6 @@ func FindRelatedAlerts(currentAlert schema.Alert) (*AlertCorrelation, error) {
106100 return nil , err
107101 }
108102
109- utils .Logger .Info ("Found %d historical alerts to analyze" , len (historicalResponses ))
110-
111103 var alertIDs []string
112104 for _ , resp := range historicalResponses {
113105 alertIDs = append (alertIDs , resp .ID )
@@ -138,43 +130,36 @@ func FindRelatedAlerts(currentAlert schema.Alert) (*AlertCorrelation, error) {
138130}
139131
140132func isAlertRelated (current , historical schema.Alert ) bool {
141- utils .Logger .Info ("Checking relation between alerts - Current: %s, Historical: %s" , current .ID , historical .ID )
133+ if current .ID == historical .ID {
134+ return false
135+ }
142136
143137 if current .Destination .IP != "" && current .Destination .IP == historical .Destination .IP {
144- utils .Logger .Info ("Match found: Destination IP %s" , current .Destination .IP )
145138 return true
146139 }
147140 if current .Destination .Port != 0 && current .Destination .Port == historical .Destination .Port {
148- utils .Logger .Info ("Match found: Destination Port %d" , current .Destination .Port )
149141 return true
150142 }
151143 if current .Destination .Host != "" && current .Destination .Host == historical .Destination .Host {
152- utils .Logger .Info ("Match found: Destination Host %s" , current .Destination .Host )
153144 return true
154145 }
155146 if current .Destination .User != "" && current .Destination .User == historical .Destination .User {
156- utils .Logger .Info ("Match found: Destination User %s" , current .Destination .User )
157147 return true
158148 }
159149
160150 if current .Source .IP != "" && current .Source .IP == historical .Source .IP {
161- utils .Logger .Info ("Match found: Source IP %s" , current .Source .IP )
162151 return true
163152 }
164153 if current .Source .Port != 0 && current .Source .Port == historical .Source .Port {
165- utils .Logger .Info ("Match found: Source Port %d" , current .Source .Port )
166154 return true
167155 }
168156 if current .Source .Host != "" && current .Source .Host == historical .Source .Host {
169- utils .Logger .Info ("Match found: Source Host %s" , current .Source .Host )
170157 return true
171158 }
172159 if current .Source .User != "" && current .Source .User == historical .Source .User {
173- utils .Logger .Info ("Match found: Source User %s" , current .Source .User )
174160 return true
175161 }
176162
177- utils .Logger .Info ("No match found between alerts %s and %s" , current .ID , historical .ID )
178163 return false
179164}
180165
0 commit comments