AWS cloudwatch 中的日志机制是什么?

What is Log Mechanism in AWS cloud watch?

我最近开始学习 AWS 云观察,我想了解创建日志的概念,所以我浏览了很多链接,比如 https://aws.amazon.com/answers/logging/centralized-logging/ 我可以理解我们可以创建日志组,但是日志基本上是为了跟踪 activity。还有什么吗?什么时候创建日志。 任何帮助将不胜感激!

您可以获得有关日志组和 CloudWatch Logs 概念的更多详细信息here

以下是该页面的摘录

Log Events

A log event is a record of some activity recorded by the application or resource being monitored. The log event record that CloudWatch Logs understands contains two properties: the timestamp of when the event occurred, and the raw event message. Event messages must be UTF-8 encoded.

Log Streams

A log stream is a sequence of log events that share the same source. More specifically, a log stream is generally intended to represent the sequence of events coming from the application instance or resource being monitored. For example, a log stream may be associated with an Apache access log on a specific host. When you no longer need a log stream, you can delete it using the aws logs delete-log-stream command. In addition, AWS may delete empty log streams that are over 2 months old.

Log Groups

Log groups define groups of log streams that share the same retention, monitoring, and access control settings. Each log stream has to belong to one log group. For example, if you have a separate log stream for the Apache access logs from each host, you could group those log streams into a single log group called MyWebsite.com/Apache/access_log.

并回答您的问题“何时创建日志。”,基本上这完全取决于您的应用程序。但是,无论何时创建它们,它们都会流式传输到 cloudwatch 流(如果您安装了 cloudwatch 代理并且正在流式传输该特定日志)

使用 cloudwatch 的优点是即使在 EC2 实例终止后您也可以保留日志,并且您不需要通过 SSH 进入资源来检查日志,您可以简单地从 AWS 控制台获取它