2

I am trying to find a way to somehow capture events that do not match a specific rule from an event bus. Below is the event-pattern for a rule that I created:

 {
  "detail": {
      "key1": ["1234"],
      "key2": ["ABC"],
      "key3": ["PHL"]
  }
}

The rule is matched and the target is invoked only if all 3 keys in the pattern are matching.

How do I log or find out the event that was unmatched by this rule and the target wasn't invoked?

Solutions I tried but failed:

Aniket Kapse
  • 315
  • 3
  • 20
  • 1
    I don't think you can do that with just EB. You may need to use lambda to analyze all the events, and match them yourselfs. – Marcin Apr 11 '22 at 10:18
  • Since I'm using EB integrated with API Gateway, the ideal way to do this would be to use lambda proxy API gateway integration and then push the events out to the EB bus from that lambda right? – Aniket Kapse Apr 12 '22 at 06:10
  • 1
    Yes, lambda would be the proxy. – Marcin Apr 12 '22 at 06:24

1 Answers1

3

Like what Marcin said ... Its possible to write a Lambda as target with a rule that matches all/most of the events in your EB. The Lambda function will

  1. Loop on ListRules for all events in your custom EB
  2. Foreach rule (not including this new Lambda), do a TestEventPattern
  3. If no matches are found, log to a DLQ

Not a pretty soln I admit ...

See:

https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_ListRules.html https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_TestEventPattern.html

Henry Chan
  • 31
  • 3