@@ -1342,6 +1342,7 @@ def _process_entry(
1342
1342
if event_failed_validation := validate_event (entry ):
1343
1343
processed_entries .append (event_failed_validation )
1344
1344
failed_entry_count ["count" ] += 1
1345
+ LOG .info (json .dumps (event_failed_validation ))
1345
1346
return
1346
1347
region , account_id = extract_region_and_account_id (event_bus_name_or_arn , context )
1347
1348
if encoded_trace_header := get_trace_header_encoded_region_account (
@@ -1355,19 +1356,36 @@ def _process_entry(
1355
1356
except ResourceNotFoundException :
1356
1357
# ignore events for non-existing event buses but add processed event
1357
1358
processed_entries .append ({"EventId" : event_formatted ["id" ]})
1359
+ LOG .info (
1360
+ json .dumps (
1361
+ {
1362
+ "ErrorCode" : "ResourceNotFoundException at get_event_bus" ,
1363
+ "ErrorMessage" : f"Event_bus { event_bus_name } does not exist" ,
1364
+ }
1365
+ )
1366
+ )
1358
1367
return
1359
1368
self ._proxy_capture_input_event (event_formatted )
1360
- matching_rules = [rule for rule in event_bus .rules .values ()]
1361
- for rule in matching_rules :
1362
- self ._process_matched_rules (
1363
- rule , region , account_id , event_formatted , processed_entries , failed_entry_count
1369
+ if configured_rules := list (event_bus .rules .values ()):
1370
+ for rule in configured_rules :
1371
+ self ._process_rules (
1372
+ rule , region , account_id , event_formatted , processed_entries , failed_entry_count
1373
+ )
1374
+ else :
1375
+ LOG .info (
1376
+ json .dumps (
1377
+ {
1378
+ "InfoCode" : "InternalInfoEvents at process_rules" ,
1379
+ "InfoMessage" : f"No rules attached to event_bus: { event_bus_name } " ,
1380
+ }
1381
+ )
1364
1382
)
1365
1383
1366
1384
def _proxy_capture_input_event (self , event : FormattedEvent ) -> None :
1367
1385
# only required for eventstudio to capture input event if no rule is configured
1368
1386
pass
1369
1387
1370
- def _process_matched_rules (
1388
+ def _process_rules (
1371
1389
self ,
1372
1390
rule : Rule ,
1373
1391
region : str ,
@@ -1379,6 +1397,15 @@ def _process_matched_rules(
1379
1397
event_pattern = rule .event_pattern
1380
1398
event_str = to_json_str (event_formatted )
1381
1399
if matches_rule (event_str , event_pattern ):
1400
+ if not rule .targets :
1401
+ LOG .info (
1402
+ json .dumps (
1403
+ {
1404
+ "InfoCode" : "InternalInfoEvents at iterate over targets" ,
1405
+ "InfoMessage" : f"No target configured for matched rule: { rule } " ,
1406
+ }
1407
+ )
1408
+ )
1382
1409
for target in rule .targets .values ():
1383
1410
target_arn = target ["Arn" ]
1384
1411
if is_archive_arn (target_arn ):
@@ -1401,3 +1428,20 @@ def _process_matched_rules(
1401
1428
}
1402
1429
)
1403
1430
failed_entry_count ["count" ] += 1
1431
+ LOG .info (
1432
+ json .dumps (
1433
+ {
1434
+ "ErrorCode" : "InternalException at process_entries" ,
1435
+ "ErrorMessage" : str (error ),
1436
+ }
1437
+ )
1438
+ )
1439
+ else :
1440
+ LOG .info (
1441
+ json .dumps (
1442
+ {
1443
+ "InfoCode" : "InternalInfoEvents at matches_rule" ,
1444
+ "InfoMessage" : f"No rules matched for formatted event: { event_formatted } " ,
1445
+ }
1446
+ )
1447
+ )
0 commit comments