Okay, here I see two primary questions:
- How to identify CloudTrail events for Signout and Forgot Password
- How to get the EmailId of users in your quicksight reports (from the
UserSub
present in CloudTrail)
On (1) identifying events for Signout and Forgot Password:
The only authentication audit events for Cognito are SignIn
, SignUp
, and ForgotPassword
. So, you can use a query on eventName = 'ForgotPassword'
for ForgotPassword events. However, there is no audit event for signouts, so you won't be able to track them this way with CloudTrail.
In order to capture sign out events, you'll need a different/additional approach to get your sign outs, which may be difficult, if even possible, depending on whether you use federated identities or not.
On (2) getting the EmailId of users in your quicksight reports:
As noted in the Cognito developer guide:
Amazon Cognito supports logging for all of the actions listed on the User Pool Actions page as events in CloudTrail log files. Amazon Cognito records UserSub but not UserName in CloudTrail logs for requests that are specific to a user
If you need more information than what CloudTrail provides inherently here, you can find a user for a given UserSub
by calling the ListUsers
API, and using a filter for the sub.
Now, in order to get the QuickSight report you want, you need to somehow process the CloudTrail output yourself to get all the data you want (e.g. processing the UserSub
using cognito APIs to get the EmailId) into a data source that can be queried with QuickSight. How you might architect this solution depends a lot on whether you need the data in realtime or not.
If you need a (near-)realtime solution, you could achieve this with a serverless setup where you stream cloudtrail -> cloudwatch logs (optionally filtered) -> kinesis streams -> stream consumer (e.g. Lambda) that processes UserSub to the data you want -> datasource for QuickSight (s3/athena/dynamodb/etc).

If you do not need a near-realtime solution, you could adopt a similar approach, except instead of streaming the log events, you might just accumulate logs in an S3 bucket. Then, periodically, you process the logs from S3 and put the processed data in the data source of your choosing connected to QuickSight.