Best Way to Monitor Customer Usage of AWS Lambda

偶尔善良 提交于 2021-02-05 08:46:27

问题


I have newly created an API service that is going to be deployed as a pilot to a customer. It has been built with AWS API Gateway, AWS Lambda, and AWS S3. With a SaaS pricing model, what's the best way for me to monitor this customer's usage and cost? At the moment, I have made a unique API Gateway, Lambda function, and S3 bucket specific to this customer. Is there a good way to create a dashboard that allows me (and perhaps the customer) to detail this monitoring?

Additional question, what's the best way to streamline this process when expanding to multiple different customers? Each customer would have a unique API token — what's the better approach than the naive way of making unique AWS resources per customer?

I am new (a college student), but any insights/resources would help me a long way. Thanks.


回答1:


Full disclosure: I work for Lumigo, a company that does exactly that.

Regarding your question, As @gusto2 said, there are many tools that you can use, and the best tool depends on your specific requirements.

The main difference between the tools is the level of configuration that you need to apply.

  • cloudwatch default metrics - The first tool that you should use. This is an out-of-the-box solution that provides you many metrics on the services, such as: duration, number of invocations and errors, memory. You can configure metrics over different timeslots and aggregators (P99, average, max, etc.) This tool is great for basic monitoring. Its limitation is its greatest strength - it provides monitoring which is common to all the services, thus nothing tailored-fit to serverless applications. https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/working_with_metrics.html https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html

  • cloudwatch custom metrics - The other side of the scale - getting much more precise metrics, which allows you to upload any metric data and monitor it: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html This is a great tool if you know exactly what you want to monitor, and you already familiar with your architecture limitations and pain points. And, of course, you can configure alarms over this data:

  • Lumigo - 3rd party company (again, as a disclosure, this is my workplace). Provides out-of-the-box monitoring, specifically created for serverless applications, such as an abnormal number of invocations, costs, etc.. This tool also provides troubleshooting capabilities to enable deeper observability.

Of course, there are more 3rd party tools that you can find online. All are great- just find the one that suits your requirement the best.




回答2:


Is there a good way to create a dashboard

There a are multiple ways and options depending in your scaling, amount of data and requirements. So you could start small and simple, but check if any option is feasible or not.

You can start with the CloudWatch. You can monitor basic metrics, create dashboards and even share with other accounts.

naive way of making unique AWS resources per customer

For the start I would consider creating custom cloudwatch metrics with the customer id as a metric and put the metrics from the Lambda functions.

Looks simple, but you should do the math and a PoC about the number of requested datapoints and the dashboards to prevent a nasty surprise on the billing.

Another option is sending metrics/events to DynamoDB, using atomic functions you could directly build some basic aggregations (kind of naïve stream processing).

When scaling to a lot of events, clients, maybe you will need some serious api analytics, but that may be a different topic.



来源:https://stackoverflow.com/questions/64626502/best-way-to-monitor-customer-usage-of-aws-lambda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!