{"id":727,"date":"2017-03-25T13:01:02","date_gmt":"2017-03-25T13:01:02","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=727"},"modified":"2017-03-25T13:01:02","modified_gmt":"2017-03-25T13:01:02","slug":"setup-aws-logs-agent-ubuntu-16","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=727","title":{"rendered":"How To Setup AWS Logs Agent on Ubuntu 16.04 Instance"},"content":{"rendered":"<p>This tutorial will guide you through the steps for configuring awslogs agent on an EC2 Ubuntu 16.04 server instance.<\/p>\n<h3 id=\"install-and-configure-awslogs\">Install and Configure AWSLogs<\/h3>\n<p>Step1: Update the system and install python. <\/p>\n<pre><code>sudo apt-get update -y\nsudo apt-get install python<\/code><\/pre>\n<p>Step2: Download the latest agent installation script. curl <\/p>\n<pre><code>curl https:\/\/s3.amazonaws.com\/aws-cloudwatch\/downloads\/latest\/awslogs-agent-setup.py -O<\/code><\/pre>\n<p>Step3: Run the agent setup command with the region parameter. Replace the <code>eu-west-2<\/code> with the aws region code where you are operating. <\/p>\n<pre><code>sudo python .\/awslogs-agent-setup.py --region us-west-2<\/code><\/pre>\n<p>Fill in the required parameters when prompted.<\/p>\n<h3 id=\"setup-awslogs-as-a-service\">Setup AWSLogs as a service<\/h3>\n<p>There is no support for creating awslogs as a service in Ubuntu 16.04. So we need to create our own systemd unit file for running it as a service.<\/p>\n<ol>\n<li>cd into <code>\/etc\/systemd\/system<\/code> directory.<\/li>\n<\/ol>\n<pre><code>cd \/etc\/systemd\/system<\/code><\/pre>\n<ol start=\"2\">\n<li>Create a file named&nbsp;<code>awslogs.service<\/code><\/li>\n<\/ol>\n<pre><code>vim awslogs.service<\/code><\/pre>\n<ol start=\"3\">\n<li>Copy the following content on the&nbsp;<code>awslogs.service<\/code>&nbsp;file.<\/li>\n<\/ol>\n<pre><code>[Unit]\nDescription=Service for CloudWatch Logs agent\nAfter=rc-local.service\n\n[Service]\nType=simple\nRestart=always\nKillMode=process\nTimeoutSec=infinity\nPIDFile=\/var\/awslogs\/state\/awslogs.pid\nExecStart=\/var\/awslogs\/bin\/awslogs-agent-launcher.sh --start --background --pidfile $PIDFILE --user awslogs --chuid awslogs &amp;\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<ol start=\"4\">\n<li>Now start the agent using the following command.<\/li>\n<\/ol>\n<pre><code>systemctl start awslogs.service<\/code><\/pre>\n<p>To stop and restart, you can use the following commands.<\/p>\n<pre><code>systemctl stop awslogs.service\nsystemctl restart awslogs.service<\/code><\/pre>\n<ol start=\"5\">\n<li>To enable&nbsp;<code>awslogs<\/code>&nbsp;service on boot, execute the following command.<\/li>\n<\/ol>\n<pre><code>systemctl enable awslogs.service<\/code><\/pre>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/setup-aws-logs-agent-ubuntu-16\/\" target=\"_blank\" rel=\"noopener noreferrer\">How To Setup AWS Logs Agent on Ubuntu 16.04 Instance \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/setup-aws-logs-agent-ubuntu-16\/<\/p>\n","protected":false},"author":1,"featured_media":728,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=727"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/727\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/728"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}