Having trouble installing awslogs agent

I am having problems installing the awslogs agent on my ec2 node. When I run this command:

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

It seems that it does not work in step 2 as follows:

 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 

which directory or file is it missing?

+10
source share
6 answers

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 
+2
source

Although this question is a bit outdated, I would like to add an answer to it, since I recently ran into the same problem, but managed to find a way around this. I tried to install this on an instance running CentOS 7.

When I run the install command for the first time, I get exactly the same error log that @ user2061886 reports. The installer logs to a file with the following path: /var/log/awslogs-agent-setup.log. I linked the file and found that internally the installer complained that it could not 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 could not get it to work with Python 2.7, so I switched to Python 3.5. To install Python 3.5 on 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 ran the installer command again and received the error message reported by @ user2061886. I could install and configure CloudWatch Logs Agent. However, shortly after starting the service (sudo service awslogs start), I ran into a second problem. This time I had to write the following file to determine the problem: /var/log/awslogs.log. Cloudwatch Log Agent mainly complained that it could not 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 manually installing the package using pip:

 pip3.5 install awscli-cwlogs. 

This solved the problem!

+1
source

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

 python-devel libpython-dev which initscripts cronie 
+1
source

^^ Yes. I fixed a similar problem with some missing dependencies pointed out in /var/log/awslogs.log


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

0
source

Amazon Linux 2

The awslogs agent is now available as the 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 

Be sure to change the AWS region as indicated in the document.

0
source

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 )

In case of the above error, you can use the "which" command and, unfortunately, "which" has not been installed. After installation, everything worked.

Hooray !! If it helps anyone.

0
source

Source: https://habr.com/ru/post/1014634/


All Articles