简体   繁体   English

如何将AWS Cloudwatch日志插入数据库中?

[英]How to insert AWS Cloudwatch logs into database?

I enabled logs for API Gateway in Cloudwatch. 我在Cloudwatch中为API网关启用了日志。 I can see the logs in the Cloudwatch console. 我可以在Cloudwatch控制台中查看日志。

Now I need to maintain a database that can store the information which contains the request method, request id, response body, and other necessary information when the API gateway method is being invoked. 现在,我需要维护一个数据库,该数据库可以存储在调用API网关方法时包含请求方法,请求ID,响应主体和其他必要信息的信息。

So that I can query to that database to see what methods are accessed in API gateway and when it is accessed and need to display it in an angular application. 这样我就可以查询该数据库,以查看在API网关中访问了哪些方法以及何时访问它,以及需要在有角度的应用程序中显示它。

I researched the same and found nothing. 我研究了同样的东西,却一无所获。

What I think: We need to use some AWS native service that scheduled for every 2 or 5 mins to read the logs of the API gateway and insert into DynamoDb or any other Database. 我的想法:我们需要使用一些每2或5分钟安排一次的AWS本机服务来读取API网关的日志并将其插入DynamoDb或任何其他数据库。 But don't know how to use. 但是不知道如何使用。

Please advise how to insert API Gateway logs into the database. 请告知如何将API Gateway日志插入数据库。 Thanks in advance 提前致谢

Storing AWS Cloudwatch logs in a Database (like MySQL/Aurora) can be expensive. 将AWS Cloudwatch日志存储在数据库(例如MySQL / Aurora)中可能会很昂贵。 The cheapest way is to store logs in AWS S3 and then maybe run Spark Jobs(AWS EMR) to analyze your data. 最便宜的方法是将日志存储在AWS S3中,然后运行Spark Jobs(AWS EMR)来分析数据。

If you are looking for AWS native service, then you can look for AWS ElasticSearch service and here is good documentation from AWS on how to stream Cloudwatch Logs to AWS ElasticSearch - https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_ES_Stream.html 如果您正在寻找AWS本地服务,那么你可以看看AWS ElasticSearch服务,这里是从AWS如何流CloudWatch的日志到AWS ElasticSearch好的文档- https://docs.aws.amazon.com/AmazonCloudWatch/latest/日志/ CWL_ES_Stream.html

Once the data is in Elasticsearch you can query and build nice visualization in Kibana dashboard. 将数据保存在Elasticsearch中后,您就可以在Kibana仪表板中查询并建立良好的可视化效果。

Hope this help. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM