Monitoring Amazon Cognito costs
Like with any other AWS service, it's important to understand the effect of your Amazon Cognito configuration and usage on your AWS bill. As part of your preparations for the deployment of user pools to production, set up monitoring and safeguards for activity and resource consumption. When you know where to look and what actions produce additional cost, you can set up precautions against surprises in your bill.
For more information about what Amazon Cognito charges for and how to reduce your usage and bill, see Managing Amazon Cognito costs.
High-volume events like product launches and opening up to new userbases can increase your MAU count and have a cost impact. Estimate the new user count in advance and watch activity as it happens. You might find that you want to accommodate the volume with a purchase of additional quota capacity, or control the volume with additional security measures.
You can view and report on your AWS costs in the AWS Billing and Cost Management consoleCognito to view your usage. For more information, see Viewing your bill in the AWS Billing User
Guide.
To monitor API request rates, review the Utilization metric in the
Service Quotas console. For example, both client_credentials grant requests to the
token endpoint and GetClientToken API requests display as Rate of ClientAuthentication
requests, because they share a request quota. In your bill, these requests are
associated with the app client that produced them. With this information, you can equitably
allocate costs to the tenants in a multi-tenant architecture.
To get a count of token-endpoint M2M requests for a period of time, you can also send
AWS CloudTrail events to CloudWatch Logs for analysis. Query your CloudTrail events
for Token_POST events with a client credentials grant. The following CloudWatch
Insights query returns this count. To include M2M requests that you make with the
GetClientToken API operation, use the Rate of ClientAuthentication
requests utilization metric described earlier in this topic.
filter eventName = "Token_POST" and @message like '"grant_type":["client_credentials"]' | stats count(*)