{"id":353,"date":"2022-05-20T09:06:22","date_gmt":"2022-05-20T09:06:22","guid":{"rendered":"http:\/\/checkmateq.com\/blog\/?p=353"},"modified":"2024-10-19T17:03:21","modified_gmt":"2024-10-19T17:03:21","slug":"cloudwatch-agent","status":"publish","type":"post","link":"https:\/\/www.checkmateq.com\/blog\/cloudwatch-agent","title":{"rendered":"How To Install CloudWatch Agent on Linux EC2 Instances"},"content":{"rendered":"<p>The AWS CloudWatch service is used for real-time monitoring and observation of <a href=\"https:\/\/www.checkmateq.com\/cloud\"><strong>AWS Cloud services<\/strong><\/a>. Logs, metrics, and events are used to collect data. We may utilise AWS CloudWatch in production environments to discover <strong>Cloud infrastructure issues<\/strong> and other <strong>cloud operations concerns<\/strong>, set alarms, and take automated actions to keep our apps running smoothly.<\/p>\n<p><strong>AWS CloudWatch Agent<\/strong> is a software package that runs continuously on our EC2 servers and provides system-level and in-guest metrics. It can also collect logs and metrics from containerized applications.<\/p>\n<p>Before installing CloudWatch Agent on our EC2 instance we need to attach an IAM role to it with appropriate permissions.<\/p>\n<p><strong>To create an IAM role follow these steps:<\/strong><\/p>\n<ul>\n<li>Go to AWS Console-&gt;IAM-&gt;Roles-&gt;Create Roles.<\/li>\n<li>Select AWS service as the trusted entity type and EC2 as use case. Click Next.<\/li>\n<li>\u00a0Enter &#8220;<strong>CloudWatchAgentServerPolicy<\/strong>&#8221; in search bar of permissons page. Select the policy and hit next.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-366\" src=\"http:\/\/checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-124330-300x39.png\" alt=\"\" width=\"738\" height=\"96\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-124330-300x39.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-124330-1024x134.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-124330-768x101.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-124330-1200x157.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-124330.png 1212w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<ul>\n<li>Give a name to your role and click on <strong>create role<\/strong>.<\/li>\n<li>Go to EC2 console. Select your instance in which you want to install CloudWatch Agent package.<\/li>\n<li>Go to Actions-&gt;Security-&gt;Modify IAM Role.<\/li>\n<li>Select the role you created and click on <strong>Save<\/strong>.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-367\" src=\"http:\/\/checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-130927-300x125.png\" alt=\"\" width=\"739\" height=\"308\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-130927-300x125.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-130927-1024x426.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-130927-768x319.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-130927-1200x499.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-130927.png 1249w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<ul>\n<li>Restart the EC2 instance.<\/li>\n<\/ul>\n<h3><strong>Steps to install the CloudWatch Agent on an Ec2 Instance:<\/strong><\/h3>\n<p><strong>Step1:<\/strong> Connect to your EC2 instance.<\/p>\n<p><strong>Step2: <\/strong>Install the cloud watch agent package. For Red Hat Machine copy the following code for downloading.<\/p>\n<pre>wget https:\/\/s3.amazonaws.com\/amazoncloudwatch-agent\/redhat\/amd64\/latest\/amazon-cloudwatch-agent.rpm\r\n<\/pre>\n<p><strong>Step3: <\/strong>Install the package. Move to the directory where you have downloaded the package and run the following command.<\/p>\n<pre>sudo rpm -U .\/amazon-cloudwatch-agent.rpm\r\n<\/pre>\n<p><strong>Step4: <\/strong>Create the configuration file with the help of cloud watch wizard. Run the following command for starting cloud watch wizard.<\/p>\n<pre>sudo \/opt\/aws\/amazon-cloudwatch-agent\/bin\/amazon-cloudwatch-agent-config-wizard\r\n<\/pre>\n<p><strong>Step6:\u00a0<\/strong>Answer the questions to customize your configuration file. Either you can select default options or choose according to your use case.<\/p>\n<p><strong>Step7:<\/strong> You can manually change the configuration file later as well. The file is located at following location.<\/p>\n<pre> \/opt\/aws\/amazon-cloudwatch-agent\/bin\/config.json\r\n<\/pre>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-379\" src=\"http:\/\/checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-150948-300x252.png\" alt=\"CloudWatch\" width=\"693\" height=\"582\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-150948-300x252.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-150948-768x644.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-150948.png 937w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p><strong>Step7:\u00a0<\/strong>Start the CloudWatch Agent with the following command.<\/p>\n<pre>sudo \/opt\/aws\/amazon-cloudwatch-agent\/bin\/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:\/opt\/aws\/amazon-cloudwatch-agent\/bin\/config.json -s\r\n<\/pre>\n<p><strong>Step8: <\/strong>The CloudWatch agent is now installed and configured on your EC2 Instance. Now, wait for a few minutes to collect the data. Goto the Cloudwatch section-&gt;Metrics-&gt; cwagent.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-371\" src=\"http:\/\/checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-143321-300x102.png\" alt=\"CloudWatch\" width=\"738\" height=\"251\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-143321-300x102.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-143321-1024x349.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-143321-768x262.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-143321-1536x524.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-143321-1200x410.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-2022-05-20-143321.png 1714w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.checkmateq.com\/contact-us\">Contact us<\/a> if you need assistance with cloud infrastructure-related issues or <a href=\"https:\/\/www.checkmateq.com\/technology-consulting\">Technology Consulting<\/a> to manage entire stack. We also help you hire experienced <a href=\"https:\/\/www.checkmateq.com\/gcp-cloud\">cloud engineer<\/a>. You can also <a href=\"https:\/\/www.checkmateq.com\/hire-developer\">Hire Dedicated software developer in India<\/a>,\u00a0 <a href=\"https:\/\/www.checkmateq.com\/virtual-cto-services\">Virtual CTO Services<\/a> for <a href=\"https:\/\/www.checkmateq.com\/cloud\">cloud strategy services in India<\/a> , <a href=\"https:\/\/www.checkmateq.com\/hire-developer\">IT staff augmentation services<\/a>, and product management best practices.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The AWS CloudWatch service is used for real-time monitoring and observation of AWS Cloud services. Logs, metrics, and events are used to collect data. We may utilise AWS CloudWatch in production environments to discover Cloud infrastructure issues and other cloud operations concerns, set alarms, and take automated actions to keep our apps running smoothly. AWS &hellip; <a href=\"https:\/\/www.checkmateq.com\/blog\/cloudwatch-agent\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How To Install CloudWatch Agent on Linux EC2 Instances&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":382,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[17,2,7,11,8],"_links":{"self":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/353"}],"collection":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/comments?post=353"}],"version-history":[{"count":21,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":4619,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/353\/revisions\/4619"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media\/382"}],"wp:attachment":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media?parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/categories?post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/tags?post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}