lightweight
lightweight

Reputation: 3327

having trouble installing awslogs agent

I'm having issues trying to instal awslogs agent on my ec2 node. When I run this command:

sudo python ./awslogs-agent-setup.py --region us-east-1

it seems to fail at step 2 like this:

Launching interactive setup of CloudWatch Logs agent ... 

Step 1 of 5: Installing pip ...DONE

Step 2 of 5: Downloading the latest CloudWatch Logs agent bits ... 
Traceback (most recent call last):
  File "./awslogs-agent-setup.py", line 1144, in <module>
    main()
  File "./awslogs-agent-setup.py", line 1140, in main
    setup.setup_artifacts()
  File "./awslogs-agent-setup.py", line 696, in setup_artifacts
    self.install_awslogs_cli()
  File "./awslogs-agent-setup.py", line 523, in install_awslogs_cli
    subprocess.call([AWSCLI_CMD, 'configure', 'set', 'plugins.cwlogs', 'cwlogs'], env=DEFAULT_ENV)
  File "/usr/lib64/python2.7/subprocess.py", line 524, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

what directory or file is it missing?

Upvotes: 13

Views: 17491

Answers (7)

Juan&#237;n
Juan&#237;n

Reputation: 851

I know I'm 2+ years late but I wasn't able to find an answer to this.

I was having the same problem and it was because the disk was running out of inodes (I think running out of disk space can cause the same problem) and I solved it running sudo apt-get autoremove

You can check your inodes with df -i

I hope this may help anyone having this problem.

Upvotes: 0

Kaustav Nandi
Kaustav Nandi

Reputation: 21

So guys Just figured it OUT!!

File "./awslogs-agent-setup.py", line 520, in install_awslogs_cli venv_in_path = (subprocess.call(["which", "virtualenv"], stderr=self.log_file, stdout=self.log_file) == 0)

On the above error, you can the "which" command is being used and unfortunately "which" was not installed. Once installed everything started working.

Cheers!! If it helps anyone.

Upvotes: 0

Cyril Duchon-Doris
Cyril Duchon-Doris

Reputation: 14009

Amazon Linux 2

The awslogs agent is available now as a yum package https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/QuickStartEC2Instance.html

sudo yum install -y awslogs
sudo systemctl start awslogsd
sudo systemctl enable awslogsd.service

Make sure to change the AWS Region as mentionned in the doc

Upvotes: 6

rednax
rednax

Reputation: 225

I had the same problem trying to install on centos docker. Turns out I could do without updating python after installing these packages

python-devel libpython-dev which initscripts cronie

Upvotes: 1

Milan Cermak
Milan Cermak

Reputation: 8064

I solved this by passing the python interpreter to be used:

sudo python ./awslogs-agent-setup.py --region us-east-1 --python=/usr/bin/python3.5

Upvotes: 5

user2966600
user2966600

Reputation: 571

^^Yeah.. I fixed a similar issue with some missing dependencies that were pointed to in the /var/log/awslogs.log


apt-get update && apt-get install -y python-pip libpython-dev

Upvotes: 0

Jose Haro Peralta
Jose Haro Peralta

Reputation: 999

Although this question is a bit old, I'd like to add an answer to it, as I recently run into the same problem, but managed to find a way around it. I was trying to install this in an instance running CentOS 7.

When I run the installation command for the first time, I got exactly the same error log reported by @user2061886. The installer logs to a file with the following path: /var/log/awslogs-agent-setup.log. I tailed the file and found that internally the installer was complaining about not being able to find the file "Python.h":

    creating build/temp.linux-x86_64-2.7
    checking if libyaml is compilable
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-
D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-
size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/check_libyaml.c -o build/temp.linux-x86_64-2.7/check_libyaml.o
checking if libyaml is linkable
gcc -pthread build/temp.linux-x86_64-2.7/check_libyaml.o -L/usr/lib64 -lyaml -o build/temp.linux-x86_64-2.7/check_libyaml
building '_yaml' extension
creating build/temp.linux-x86_64-2.7/ext
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o
ext/_yaml.c:4:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

I couldn't get it working with Python 2.7, so I switched to Python 3.5. To install Python 3.5 in CentOS 7:

yum -y udpate

yum install -y epel-release

yum install -y http://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-
release-1.0-13.ius.centos7.noarch.rpm

yum -y update

yum install -y python35u*

I run again the installer command and got passed the error reported by @user2061886. I could install and configure the CloudWatch Logs Agent. However, soon after I started the service (sudo service awslogs start), I run into a second problem. This time I had to tail the following file to spot the issue: /var/log/awslogs.log. The cloudwatch logs agent was basically complaining about not being able to find the cwlogs package:

Traceback (most recent call last):
  File "/var/awslogs/bin/aws", line 27, in <module>
    sys.exit(main())
  File "/var/awslogs/bin/aws", line 23, in main
    return awscli.clidriver.main()
  File "/usr/lib/python3.5/site-packages/awscli/clidriver.py", line 55, in main
    driver = create_clidriver()
  File "/usr/lib/python3.5/site-packages/awscli/clidriver.py", line 64, in create_clidriver
    event_hooks=emitter)
  File "/usr/lib/python3.5/site-packages/awscli/plugin.py", line 44, in load_plugins
    modules = _import_plugins(plugin_mapping)
  File "/usr/lib/python3.5/site-packages/awscli/plugin.py", line 58, in _import_plugins
    plugins.append(__import__(path))
ImportError: No module named 'cwlogs'

I solved this by installing the package manually with pip:

pip3.5 install awscli-cwlogs. 

This got the problem solved!

Upvotes: 2

Related Questions