Logstash drop based on size

Hi all,

Is it possible to drop a message based on it's size (ex: above 1 MB)?

I'm reading from tcp port and writing into Kafka topic.
All messages bigger then 1 MB give errors similar to this and then logstash retry to send
it again, giving same error:

"producer send failed {:exception=>Java::JavaUtilConcurrent::ExecutionException, :message=>"org.apache.kafka.common.errors.RecordTooLargeException: The message is 8842365 bytes when serialized which is larger than the maximum request size you have configured with the max.request.size configuration."

Thank you

Answered here.

Thank you for your prompt reply!