

Kafka and Amazon MQ messages must be UTF-8 encoded strings, either plain strings or in JSON format. For Amazon MQ, Lambda acknowledges matched messages after successfully invoking the function and acknowledges unmatched messages when filtering them. For Kafka, Lambda commits offsets for matched and unmatched messages after successfully invoking the function.

Lambda drops messages that don't match all fields included in the filter. For Kafka sources ( Amazon MSK and self-managed Apache Kafka), there are two message fields: key and value. The following table summarizes the specific behavior:Īfter you attach filter criteria to a Kafka or Amazon MQ event source mapping, it can take up to 15 minutes to apply your filtering rules to events.įor Amazon MQ sources, the message field is data. For DynamoDB, the data field isĭynamodb.) If either field isn't in a valid JSON format, Lambda drops the message or throws anĮxception. To properly filter events from Kinesis and DynamoDB sources, both the data field and your filter criteria for the dataįield must be in valid JSON format. If you want records to be deleted sooner, see Period, Kinesis and DynamoDB automatically delete these old records. If the recordĭoesn't satisfy your filter criteria, you don't have to manually delete the record from your event source. Once your filter criteria processes an Kinesis or DynamoDB record, the streams iterator advances past this record. Properly filtering Kinesis and DynamoDB messages If you don't include body as part of your FilterCriteria, Lambda skips thisĬheck. Lambda filters (on the other metadata properties only) based on your filter criteria. Lambda filters based on your filter criteria. If there is a mismatch, Lambda drops the message. Messages, Lambda automatically evaluates the format of the incoming message body and of your filter The expected format of body in messages that you receive from your queue. To avoid this issue, ensure that the format of body in your FilterCriteria matches True-if the incoming message body is in JSON format but your filter criteria expects body to be a plain string, this can lead to unintended However, this can be problematic if yourįilterCriteria expect body to be in a valid JSON format. You don't have to manually delete these messages in Amazon SQS.įor Amazon SQS, the message body can be any string. If an Amazon SQS message doesn't satisfy your filter criteria, Lambda automatically removes the message from the filter-criteria " " Properly filtering Amazon SQS messages For example, here's a JSON filter pattern that contains multiple values for "duplicateKey":

If a pattern contains duplicate keys with different values, Lambda uses only the last value for that key. Lambda ignores the fields that aren't included in a filter. For Lambda to consider the event a match, the event must contain all theįield names included in a filter. When you create a FilterCriteria object, specify only the metadata properties and data properties For more information, see Filter rule syntax. The syntax of your filter rule depends on the comparison In the example FilterCriteria, rule1 applies to Metadata1,Īnd rule2 applies to Data1. For DynamoDB event sources, the data key isįilter rules define the filter that you want to apply to a specific For Kinesis event sources, the data key is data. To filter on data properties, make sure to contain them in FilterCriteria within the proper key.
