skip to Main Content

Metrics of AWS Cognito show number of SignIns on whole userpool. Is it possible to get number of SignIns by user group inside the pool?
Or number of SignIns by one specific user.

I tried to find something in doc and found nothing, but may be it have some workaround or I missed something.

2

Answers


  1. In order to achieve this, take a param in the event from the frontend.Take a hardcoded text like "SUCCESS" with the primary key along with it. For example,
    //SUCCESS should be the hardcoded value from frontend as well.

        if (event.signedUp == "SUCCESS") {
                        let updateCount = {
                            TableName: "your_table_name",
                            Key: {
                                partitionKey: partition_key
                            },
                            UpdateExpression: 'Add signUpCount :signUpCount ',
                            ExpressionAttributeValues: {
                                ':signUpCount ': 1,
                            }
                        };
                       await update_dynamo(updateCount);//I've defined the  function already
    
    In this way, everytime a user signs in, the count gets updated.
    
    Login or Signup to reply.
  2. Cognito allows you to attach lambda triggers to multiple points in the authentication process.
    You can attach a lambda function to the pre token generation trigger.
    https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html

    In your function you can do many things.

    1. Create a cloud watch log entry with user info that can be viewed.
      https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html

    2. Trigger a cloud watch action.
      https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/cloudwatch-examples-using-alarm-actions.html

    3. Create a db entry with a timestamp and create your own hi to view the data.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search