@@ -121,14 +121,18 @@ func isDuplicate(alert *plugins.Alert) bool {
121121 // Compile regex for array index stripping
122122 reArrayIndex := regexp .MustCompile (`\.[0-9]+(\.|$)` )
123123
124+ var execute bool = false
125+
124126 for _ , d := range alert .DeduplicateBy {
125127 d = strings .TrimSuffix (d , ".keyword" )
126128
127129 value := gjson .Get (* alertString , d )
128130 if value .Type == gjson .Null {
129- return false
131+ continue
130132 }
131133
134+ execute = true
135+
132136 // Calculate OpenSearch field name by removing array indices
133137 searchField := reArrayIndex .ReplaceAllStringFunc (d , func (s string ) string {
134138 if strings .HasSuffix (s , "." ) {
@@ -146,6 +150,10 @@ func isDuplicate(alert *plugins.Alert) bool {
146150 }
147151 }
148152
153+ if ! execute {
154+ return false
155+ }
156+
149157 // Create QueryBuilder and inject the Bool query
150158 qb := sdkos .NewQueryBuilder (ctx , indices , "plugin_com.utmstack.alerts" )
151159 qb .Size (1 )
@@ -209,14 +217,18 @@ func getPreviousAlertId(alert *plugins.Alert) *string {
209217 // Compile regex for array index stripping
210218 reArrayIndex := regexp .MustCompile (`\.[0-9]+(\.|$)` )
211219
220+ var execute bool = false
221+
212222 for _ , d := range alert .GroupBy {
213223 d = strings .TrimSuffix (d , ".keyword" )
214224
215225 value := gjson .Get (* alertString , d )
216226 if value .Type == gjson .Null {
217- return nil
227+ continue
218228 }
219229
230+ execute = true
231+
220232 // Calculate OpenSearch field name by removing array indices
221233 searchField := reArrayIndex .ReplaceAllStringFunc (d , func (s string ) string {
222234 if strings .HasSuffix (s , "." ) {
@@ -234,6 +246,10 @@ func getPreviousAlertId(alert *plugins.Alert) *string {
234246 }
235247 }
236248
249+ if ! execute {
250+ return nil
251+ }
252+
237253 // Create QueryBuilder and inject the Bool query
238254 qb := sdkos .NewQueryBuilder (ctx , indices , "plugin_com.utmstack.alerts" )
239255 qb .Size (1 )
0 commit comments