Get Started Monitoring NGINX With Amplify

Get Started Monitoring NGINX With Amplify

July 18, 2020 / Eternal Team

NGINX Amplify is a SaaS‑based monitoring tool for the open-source NGINX software and NGINX Plus. With NGINX Amplify you can monitor performance, keep track of infrastructure assets, and improve configuration with static analysis. NGINX Amplify also monitors the underlying OS, application servers (like PHP‑FPM), databases, and other components. NGINX Amplify is simple to set up, yet powerful enough to provide critical insight into NGINX and system performance.

It monitors and displays Nginx metrics such as.

  1. Current connections
  2. Current requests
  3. HTTP errors
  4. HTTP version
  5. Nginx memory usage
  6. Nginx CPU usage
  7. Nginx traffic

The basic version is free and also provide so many other features like.

  • Amplify WAF
  • Nginx Amplify
  • Nginx controller
  • Nginx plus

More information please visit this link.

Before you install the Amplify agent on your instance there some prerequisites you have to keep in mind.

  1. You need to have Root access
  2. Port number 80 and 443 will also be open in the security group

get-started-monitoring-nginx-with-amplify

Step 1

Sign up in Nginx Amplify website, First, you need to create your Account on Amplify Link

Step 2

Login in via SSH to your running Ubuntu instance and update patches

# apt-get update -y
# apt-get upgrade -y

Install nginx,

# apt-get install nginx python2.7 -y

Start the nginx server using

# systemctl start nginx
# systemctl enable nginx

Once you logged-in to Amplify click on the create button so you will get a screen like this so apply this command on your terminal.

get-started-monitoring-nginx-with-amplify

Once the installation has been completed successfully, apply the following command.

# service amplify-agent status

Output

amplify-agent.service - NGINX Amplify Agent

Loaded: loaded (/lib/systemd/system/amplify-agent.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2019-06-08 15:14:21 UTC; 1min 19s ago
Docs: https://amplify.nginx.com/docs/
Process: 4228 ExecStart=/etc/init.d/amplify-agent start (code=exited, status=0/SUCCESS)
Main PID: 4306 (amplify-agent)
Tasks: 3 (limit: 1718)
CGroup: /system.slice/amplify-agent.service
└─4306 amplify-agent


Jun 08 15:14:18 ubuntu1804 systemd[1]: Starting NGINX Amplify Agent...
Jun 08 15:14:21 ubuntu1804 systemd[1]: amplify-agent.service: Can't open PID file
/var/run/amplify-agent/amplify-agent.pid (yet?) after start:
Jun 08 15:14:21 ubuntu1804 systemd[1]: Started NGINX Amplify Agent.

Now click on the “continue” button and you will see like this page.

get-started-monitoring-nginx-with-amplify

Time to configure and visualize crucial metrics.

# nano /etc/nginx/conf.d/stub_status.conf

Add the following lines.

server {
listen 127.0.0.1:80;
server_name 127.0.0.1;
location /nginx_status {
stub_status on;
allow 127.0.0.1;
deny all;
}
}

Note You should write your server IP address instead of 127.0.0.1, Save and close the file when you are finished.

reload the Nginx service to activate the stub_status module

# kill -HUP `cat /var/run/nginx.pid

Modifly error_log and access_log in /etc/nginx/nginx.conf file.

# nano /etc/nginx/nginx.conf

1. For the error log, The attribute reads as shown below.

error_log /var/log/nginx/error.log warn;

2. For access_log Edit this attribute as shown.

access_log /var/log/nginx/access.log main_ext

log_format Finally, make the changes to this attribute as shown.

log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' '"$host" sn="$server_name" ' 'rt=$request_time ' 'ua="$upstream_addr" us="$upstream_status" ' 'ut="$upstream_response_time" ul="$upstream_response_length" ' 'cs=$upstream_cache_status' ;

Reload Nginx and click on ‘Finish’ button.

#systemctl restart nginx

Tada, and it’s done. Now, wait for some time.

get-started-monitoring-nginx-with-amplify

get-started-monitoring-nginx-with-amplify

get-started-monitoring-nginx-with-amplify

And if something goes wrong you will get notified via email like this.

get-started-monitoring-nginx-with-amplify

For more information, you can check out the Nginx Amplify official documentation at https://amplify.nginx.com/docs/guide-how-nginx-amplify-agent-works.html .

AWS-Consulting-Partner

Talk to AWS Certified Consultant

Want to start a project?

It’s simple.

Contact us