{"id":11835,"date":"2019-03-17T13:34:08","date_gmt":"2019-03-17T13:34:08","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11835"},"modified":"2019-03-17T13:34:08","modified_gmt":"2019-03-17T13:34:08","slug":"amplify-nginx-monitoring-made-easy","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/amplify-nginx-monitoring-made-easy\/","title":{"rendered":"Amplify \u2013 NGINX Monitoring Made Easy"},"content":{"rendered":"<p><strong>Nginx<\/strong>\u00a0amplify is a collection of useful tools for extensively monitoring a open source Nginx web server and NGINX Plus. With NGINX Amplify you can monitor performance, keep track of systems running Nginx and enables for practically examining and fixing problems associated with running and scaling web applications.<\/p>\n<p>It can be used to visualize and determine a Nginx web server performance bottlenecks, overloaded servers, or potential DDoS attacks; enhance and\u00a0<a href=\"https:\/\/www.tecmint.com\/nginx-web-server-security-hardening-and-performance-tips\/\" target=\"_blank\" rel=\"noopener\">optimize Nginx performance<\/a>\u00a0with intelligent advice and recommendations.<\/p>\n<p>In addition, it can notify you when something is wrong with the any of your application setup, and it also serves as a web application capacity and performance planner.<\/p>\n<p>The Nginx amplify architecture is built on 3 key components, which are described below:<\/p>\n<ul>\n<li><strong>NGINX Amplify Backend<\/strong>\u00a0\u2013 the core system component, implemented as a SaaS (Software as a Service). It incorporates scalable metrics collection framework, a database, an analytics engine, and a core API.<\/li>\n<li><strong>NGINX Amplify Agent<\/strong>\u00a0\u2013 a Python application which should be installed and run on monitored systems. All communications between the agent and the SaaS backend are done securely over SSL\/TLS; all traffic is always initiated by the agent.<\/li>\n<li><strong>NGINX Amplify Web UI<\/strong>\u00a0\u2013 a user interface compatible with all major browsers and it is only accessible only via TLS\/SSL.<\/li>\n<\/ul>\n<p>The web UI displays graphs for Nginx and operating system metrics, allows for the creation of a user-defined dashboard, offers a static analyzer to improve Nginx configuration and an alert system with automated notifications.<\/p>\n<h3>Step 1: Install Amplify Agent on Linux System<\/h3>\n<p><strong>1.<\/strong>\u00a0Open your web browser, type the address below and create an account. A link will be sent to your email, use it to verify the email address andlogin to your new account.<\/p>\n<pre>https:\/\/amplify.nginx.com\r\n<\/pre>\n<p><strong>2.<\/strong>\u00a0After that, log into your remote server to be monitored, via SSH and download the nginx amplify agent auto-install script using\u00a0<strong>curl<\/strong>\u00a0or\u00a0<a href=\"https:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">wget command<\/a>.<\/p>\n<pre>$ wget https:\/\/github.com\/nginxinc\/nginx-amplify-agent\/raw\/master\/packages\/install.sh\r\nOR\r\n$ curl -L -O https:\/\/github.com\/nginxinc\/nginx-amplify-agent\/raw\/master\/packages\/install.sh \r\n<\/pre>\n<p><strong>3.<\/strong>\u00a0Now run the command below with superuser privileges using the\u00a0<a href=\"https:\/\/www.tecmint.com\/su-vs-sudo-and-how-to-configure-sudo-in-linux\/\" target=\"_blank\" rel=\"noopener\">sudo command<\/a>, to install the amplify agent package (the\u00a0<strong>API_KEY<\/strong>\u00a0will probably be different, unique for every system that you add).<\/p>\n<pre>$ sudo API_KEY='e126cf9a5c3b4f89498a4d7e1d7fdccf' sh .\/install.sh \r\n<\/pre>\n<div id=\"attachment_28324\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/install-nginx-amplify-agent-.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28324\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/install-nginx-amplify-agent-.png\" sizes=\"auto, (max-width: 803px) 100vw, 803px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/install-nginx-amplify-agent-.png 803w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/install-nginx-amplify-agent--768x472.png 768w\" alt=\"Install Nginx Amplify Agent\" width=\"803\" height=\"494\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install Nginx Amplify Agent<\/p>\n<\/div>\n<p><strong>Note<\/strong>: You will possibly get an error indicating that\u00a0<strong>sub_status<\/strong>\u00a0has not been configured, this will be done in the next step.<\/p>\n<p><strong>4.<\/strong>\u00a0Once the installation is complete, go back to the web UI and after about 1 minute, you will be able to see the new system in the list on the left.<\/p>\n<h3>Step 2: Configure stub_status in NGINX<\/h3>\n<p><strong>5.<\/strong>\u00a0Now, you need to setup\u00a0<strong>stub_status<\/strong>\u00a0configuration to build key\u00a0<strong>Nginx<\/strong>\u00a0graphs (<strong>Nginx Plus<\/strong>\u00a0users need to configure either the\u00a0<strong>stub_status<\/strong>\u00a0module or the\u00a0<strong>extended status<\/strong>\u00a0module).<\/p>\n<p>Create a new configuration file for\u00a0<strong>stub_status<\/strong>\u00a0under\u00a0<strong>\/etc\/nginx\/conf.d\/<\/strong>.<\/p>\n<pre>$ sudo vi \/etc\/nginx\/conf.d\/sub_status.conf\r\n<\/pre>\n<p>Then copy and paste the following\u00a0<strong>stub_status<\/strong>\u00a0configuration in the file.<\/p>\n<pre>server {\r\n    listen 127.0.0.1:80;\r\n    server_name 127.0.0.1;\r\n    location \/nginx_status {\r\n        stub_status;\r\n        allow 127.0.0.1;\r\n        deny all;\r\n    }\r\n}\r\n<\/pre>\n<p>Save and close the file.<\/p>\n<p><strong>6.<\/strong>\u00a0Next, restart Nginx services to activate the\u00a0<strong>stub_status<\/strong>\u00a0module configuration, as follows.<\/p>\n<pre>$ sudo systemctl restart nginx\r\n<\/pre>\n<h3>Step 3: Configure Additional NGINX Metrics for Monitoring<\/h3>\n<p><strong>7.<\/strong>\u00a0In this step, you need to setup additional Nginx metrics to keep a close eye on your applications performance. The agent will gather metrics from active and growing\u00a0<strong>access.log<\/strong>\u00a0and\u00a0<strong>error.log<\/strong>\u00a0files, whose locations it automatically detects. And importantly, it should be allowed to read these files.<\/p>\n<p>All you have to do is define a specific\u00a0<strong>log_format<\/strong>\u00a0as the one below in your main Nginx configuration file,\u00a0<strong>\/etc\/nginx\/nginx.conf<\/strong>.<\/p>\n<pre>log_format main_ext '$remote_addr - $remote_user [$time_local] \"$request\" '\r\n                                '$status $body_bytes_sent \"$http_referer\" '\r\n                                '\"$http_user_agent\" \"$http_x_forwarded_for\" '\r\n                                '\"$host\" sn=\"$server_name\" ' 'rt=$request_time '\r\n                                'ua=\"$upstream_addr\" us=\"$upstream_status\" '\r\n                                'ut=\"$upstream_response_time\" ul=\"$upstream_response_length\" '\r\n                                'cs=$upstream_cache_status' ;\r\n<\/pre>\n<p>Then use the above log format when defining your\u00a0<strong>access_log<\/strong>\u00a0and the\u00a0<strong>error_log<\/strong>\u00a0log level should be set to\u00a0<strong>warn<\/strong>as shown.<\/p>\n<pre>access_log \/var\/log\/nginx\/suasell.com\/suasell.com_access_log main_ext;\r\nerror_log \/var\/log\/nginx\/suasell.com\/suasell.com_error_log  warn;\r\n<\/pre>\n<p><strong>8.<\/strong>\u00a0Now restart Nginx services once more, to effect the latest changes.<\/p>\n<pre>$ sudo systemctl restart nginx\r\n<\/pre>\n<h3>Step 4: Monitor Nginx Web Server Via Amplify Agent<\/h3>\n<p><strong>9.<\/strong>\u00a0Finally, you can begin monitoring your Nginx web server from the\u00a0<strong>Amplify Web UI<\/strong>.<\/p>\n<div id=\"attachment_28325\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/nginx-amplify-overview.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28325\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/nginx-amplify-overview.png\" sizes=\"auto, (max-width: 1137px) 100vw, 1137px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/nginx-amplify-overview.png 1137w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/nginx-amplify-overview-768x504.png 768w\" alt=\"Nginx Amplify Overview\" width=\"1137\" height=\"746\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Nginx Amplify Overview<\/p>\n<\/div>\n<div id=\"attachment_28326\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/nginx-amplify-graphs-interface.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28326\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/nginx-amplify-graphs-interface.png\" sizes=\"auto, (max-width: 1137px) 100vw, 1137px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/nginx-amplify-graphs-interface.png 1137w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/01\/nginx-amplify-graphs-interface-768x504.png 768w\" alt=\"Nginx Amplify Graph\" width=\"1137\" height=\"746\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Nginx Amplify Graph<\/p>\n<\/div>\n<p>To add a another system to monitor, simply go to\u00a0<strong>Graphs<\/strong>\u00a0and click on \u201c<strong>New System<\/strong>\u201d and follow the steps above.<\/p>\n<p><strong>Nginx Amplify Homepage<\/strong>:\u00a0<a href=\"https:\/\/amplify.nginx.com\/signup\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/amplify.nginx.com\/signup\/<\/a><\/p>\n<p><strong>Amplify<\/strong>\u00a0is a powerful SaaS solution for monitoring your OS, Nginx web server as well as Nginx based applications. It offers a single, unified web UI for keeping an eye on multiple remote systems running Nginx.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/amplify-nginx-monitoring-tool\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nginx\u00a0amplify is a collection of useful tools for extensively monitoring a open source Nginx web server and NGINX Plus. With NGINX Amplify you can monitor performance, keep track of systems running Nginx and enables for practically examining and fixing problems associated with running and scaling web applications. It can be used to visualize and determine &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/amplify-nginx-monitoring-made-easy\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Amplify \u2013 NGINX Monitoring Made Easy&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11835","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11835"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11835\/revisions"}],"predecessor-version":[{"id":11836,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11835\/revisions\/11836"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}