Amplify is a powerful, lightweight, and intuitive SaaS-based monitoring platform used for monitoring Nginx and Nginx Plus. It monitors and displays Nginx metrics such as
- Current connections
- Current requests
- HTTP errors
- HTTP version
- Nginx memory usage
- Nginx CPU usage
- Nginx traffic
In addition, it also monitors the Operating system’s metrics such as CPU usage, Load average, Memory usage, Network traffic, and Swap space. In this guide, we will learn how you can monitor Nginx with Amplify monitoring SaaS platform.
Prerequisites
- An instance of Nginx installed on a server. Recommended Read: Install Nginx on Ubuntu 18.04
- SSH access to the server. Recommended Read: SSH Command in Linux
In this guide, we have an instance of Nginx installed on a CentOS 7 server system (Hostname: spikey).
Let’s jump right in and see how we can monitor Nginx with Amplify.
Step 1: Sign up in Nginx Amplify website
First off, you need to create an account to get started with configuration. Follow this link to create an account in Amplify site.
Thereafter, you will receive an email notification with a confirmation link. Click on the link to Sign in to Amplify.
Step 2: Download the Amplify Install script
Upon logging in, the following page will be displayed with instructions to follow. First on the line will be logging into your server via SSH.
The next step will be to download the install script using either curl or wget command:
# wget https://github.com/nginxinc/nginx-amplify-agent/raw/master/packages/install.sh
Sample Output
Step 3: Install the Amplify Agent Package
Next, run the second command to install Amplify Agent package
# API_KEY='bf7dfaa516e060f9b3b1fe527d48466d' sh ./install.sh
Sample Output
After successfully installing the Amplify agent package, the server will be listed on Amplify and metrics will start being gathered.
Hit the ‘Continue’ button to go to the next step.
Step 4: Configure Nginx to visualize crucial metrics
The next page will display another set of instructions as shown. Change your present working directory to /etc/nginx
# cd /etc/nginx
Next, verify that conf.d
files are automatically added in Nginx configuration
grep -i include.*conf nginx.conf
Next, create a new file called stub_status.conf
# cat > conf.d/stub_status.conf
Copy and paste the following content into the file
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;
}
}
Verify that the stub_status.conf
file was added
Sample Output
Next, run the command below to reload Nginx for the stub_status module to become active.
kill -HUP `cat /var/run/nginx.pid`
Click on the ‘Continue’ button to proceed to the Next page.
Step 5: Modify the nginx.conf file
The final step will require modifying the /etc/nginx/nginx.conf
file. We are specifically going to make adjustments to 3 sections
error_log
Ensure that the attribute reads as shown below
error_log /var/log/nginx/error.log warn;
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.
We’re good to go now! Be sure to observe as the metrics start streaming on the graphs as shown
To have a more general view of your Nginx application, click on ‘OVERVIEW’
Thank you for coming this far. Feel free to send your feedback in the comments sections below.