AWS Cloudwatch 日志状态显示 运行 但日志在 AWS 控制台中不可用

AWS Cloudwatch logs status shows running but logs are not available in AWS console

我是aws新手,需要将应用服务日志发布到cloud watch。我尝试了 AWS 文档中提到的步骤及其工作。我通过 jenkins 管道配置了相同的步骤。在这里,我面临一个问题。日志未发布,即我无法从 AWS 控制台看到日志。我登录到 ec2 实例并检查 cloudwatch 服务状态,它显示

{
  "status": "running",
  "starttime": "2021-03-25T07:40:21+0000",
  "configstatus": "configured",
  "cwoc_status": "stopped",
  "cwoc_starttime": "",
  "cwoc_configstatus": "not configured",
  "version": "1.247347.3b250378"
}

不明白这里有什么问题:(。

任何帮助都会有所帮助。

提前致谢。

我关注了你提到的link Installing and Running the CloudWatch Agent on Your Servers

下面是我用于推送日志和一些其他指标的配置,由这个命令生成

Run the CloudWatch Agent Configuration Wizard

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
{
        "agent": {
                "metrics_collection_interval": 60,
                "run_as_user": "root"
        },
        "logs": {
                "logs_collected": {
                        "files": {
                                "collect_list": [
                                        {
                                                "file_path": "/var/log/messages",
                                                "log_group_name": "messages",
                                                "log_stream_name": "{instance_id}"
                                        }
                                ]
                        }
                }
        },
        "metrics": {
... # metrics configuration here
        }
}

按照文档中的描述启动客户端

/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a \
fetch-config -m ec2 -s -c file:///opt/aws/amazon-cloudwatch-agent/bin/config.json

Start the CloudWatch Agent Using the Command Line

# /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status
{
  "status": "running",
  "starttime": "2021-03-26T11:46:14+0000",
  "version": "1.247345.35"
}

有问题可以到logs目录里面找

[root@ip-xx amazon-cloudwatch-agent]# ls
amazon-cloudwatch-agent.log  configuration-validation.log  state
[root@ip-xx amazon-cloudwatch-agent]# pwd
/var/log/amazon/amazon-cloudwatch-agent

附带说明一下,如果我只想将日志推送到 cloudwatch,我会使用这个

Quick Start: Install and Configure the CloudWatch Logs Agent on a Running EC2 Linux Instance