Send event logs to aws cloudtrail or cloudwatch

my keycloak is an ec2 in aws and I want to send event logs(user login, user created, user delete etc) to cloudtrail or cloudwatch. What is the best way to do it?

Write your custom event listener!
I’ve done this years ago with AWS SNS as an example destination, you can find the code here: keycloak-extensions-demo/event-listener/src/main/java/dasniko/keycloak/events/AwsSnsEventListenerProvider.java at main · dasniko/keycloak-extensions-demo · GitHub (and also the respective ...Factory class, in the same package).