Priyanka
Priyanka

Reputation: 55

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

I am new to aws and I have to publish the application service logs to cloud watch. I tried the steps mentioned in AWS documentation and its working. I configured the same steps via jenkins pipeline. Here i am facing an issue. Logs are not getting published i.e. I could not see the logs from AWS console. I logged on to the ec2 instance and check the cloudwatch service status and it shows

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

Don't understand what is wrong here :(.

Any help would be helpful.

Thanks in advance.

Upvotes: 1

Views: 4555

Answers (1)

samtoddler
samtoddler

Reputation: 9625

I followed the link mentioned by you Installing and Running the CloudWatch Agent on Your Servers.

Below is my configuration for pushing the logs and few other metrics, which is generated by this command

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
        }
}

Started the client as described in the doc

/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"
}

enter image description here

You can look for troubles inside the logs directory if there are any

[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

On the side note if I just want to push the logs to cloudwatch, I would use this one

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

Upvotes: 2

Related Questions