Supercharge your webserver monitoring with Nginx Amplify
Nginx is now the most used web server among the top 1 million websites, because of fast processing speed and ability to handle large numbers of connections concurrently. Along with that, configuration that needs to be done to serve clients is minimal and easy. But however, Application developers need a tool that can monitor the server. Usually logs should be checked, specialized settings should be implemented, and related metrics should be collected and well understood. It’s easy to get lost in the process while configuring or choosing the things for the monitoring process. To address this problem, Nginx developers came up with Amplify tool which does the job with real ease.
A public beta of NGINX Amplify was released in 2016. It is a cloud‑based tool that gives you the visibility and control of NGINX and NGINX‑delivered applications.
It basically has two components. One is NGINX amplifying Server and another is Amplify Client (Agent). Amplify client is configured on the instances where NGINX is running. The client is responsible for capturing and sending the data to the Amplify Server. It basically monitors NGINX and provides configuration analysis, graphs for specific metrics, dashboards that combine several metrics, and alerts.
In this post, we will walk you through the steps for creating Amplify account and installing the agent on each of your NGINX servers. Later, we show you how to get started monitoring NGINX, including setting up an initial set of graphs, creating a simple dashboard, setting up an alert, and stepping through the configuration analysis.
Things to do before you start
- Upgrade to the latest version of Nginx or Nginx Plus.
- Check that you are using a supported Linux distribution. As of this writing, supported distributions include Amazon Linux, CentOS, Debian, Red Hat Linux, and Ubuntu.
- Check that your Python version is supported. As of this writing, Python version 2.6 and 2.7 are supported — Python 3 is not.
- To get a full range of metrics configure the Stub Status module. For NGINX Plus, which delivers additional metrics, configure the extended Status module instead.
- Make sure the directory and the configuration file where stub_status is defined are readable by the NGINX Amplify agent; if so, the agent accesses them automatically.
- For even more metrics, make a few simple changes to your log format configuration, then reload NGINX for the changes to take effect.
Creating an Amplify Account
Follow these simple steps to get started :
- Visit the NGINX Amplify signup page.
- Fill in the form and agree to the Terms of Service.
- Click Sign up.
4. In the new dialog that appears, fill in the additional information about yourself. Click Next.
Congratulations! You now have access to NGINX Amplify.
Installing the NGINX Amplify Client on your servers
Soon after creating account, you will be having option to add server on the left side. When you click on the adding server/system you will be given instructions for the configuring the amplify client.
Follow these easy steps to configure the client on each of your servers.
- Log in to your server instance as root user or a user who has permission to use sudo command.
- Run the command to download the installation script.
# curl -L -O https://raw.githubusercontent.com/nginxinc/nginx‑amplify‑agent/master/packages/install.sh
3. Then run the
install.sh script using your API_KEY (you can copy and paste the text below, but make sure to copy and paste the actual API_KEY from the on‑screen instructions in NGINX Amplify). For example:
# API_KEY='1234567890abcdef' sh ./install.sh
The installation process begins and you can see progress in the terminal.
4. After about a minute, check that the server appears in the Systems area of the Graphs page.
5. Repeat the procedure above for all servers that need monitoring.
As you add servers, graphs appear in the preview area of the Graphs page, displaying predefined metrics for each server. Within a few minutes, the graphs begin populating with the collected statistics.
After adding some of the servers your amplify account will be something like the following
Amplify comes with many functionalities. It provides a Dashboards page, where you can configure custom graphs to report metrics of your choice. You can perform various operations on the incoming data, including filtering, summation and averaging of multiple metrics, and more. You can use dashboards to monitor NGINX on specific servers or groups of servers, and to track specific microservices, entire applications, and more.
For an example lets create a dashboard showcasing the 4XX errors from a server.
- Click the Dashboard link
- Click on the Add Graph
- Enter a Title for your graph(You can name something like Servername+_4XXErrors).
- Select the metric from the drop down list. For our case it’s nginx.http.status.4xx .You can see in the list there are so many things to choose from.
- Choose an NGINX instance from the drop‑down menu labelled Click to select NGINX. That’s it. If you click save now, Amplify will monitor your server for 4XX Error.
- If you want specific status error like 401, then you can click Apply filter. Click the drop‑down menu that appears, Click to select filter key. Choose the key value from the list; since we are filtering by HTTP status code in this scenario, it’s $status. Click Type or select filter value. Type 401, and click the words Use 401 as value, which appear as you type. (The filter doesn’t take effect if you type a value but don’t click the words that appear.)
7. Just saved graph will appear showcasing the no of 4XX errors versus time.
AAA : Adding An Alert
Another feature of the Amplify is that it can alert you if something(metric) reaches or goes beyond the threshold value. Adding it in amplify is not so difficult thing. Adding alert is very important as an alert can tell you about the problem before it is visible/affecting to large group of people. And thanks to alerts you will be not last to know about the problem.
One of the limitation is that you can’t create alerts based on summaries or averages across a set of servers/systems.
Note: Every NGINX Amplify account has one predefined alert: you are alerted if NGINX Amplify goes down for more than two minutes. Remove this alert if you don’t need it.
Follow these steps to create an alert for checking a threshold for incoming bytes:
- On the Alerts page, click the Add new alert bar at the bottom of the page. The Create new alert dialog appears.
- Click the drop‑down menu labeled Click to select metric and click on a metric. (To narrow the list of choices to those that include a specific text string, type the string.)
- When you select a metric, more fields appear where you choose the factors to compare the metric against, such as a period of time and a threshold value. In below Figure, we’ve created an alert(nginx.http.status.5xx) that triggers when the number of internal server error (5XX) exceeds 10 in 2 minutes.
- Optionally, specify one of your Systems which the alert applies to.
- Enter the Email address to notify when the alert is triggered. If the email address has not been previously used with NGINX Amplify, the system sends a verification email.
- Click Create alert.
Report About a System Configuration
After installing the agent software on a server, Amplify analyzes your configuration and generates a detailed report. The report includes status information and configuration advice:
- Status information. The current state of your NGINX instance, including the NGINX version, an overview of your configuration (including modules), security advisories, virtual servers, and SSL/TLS information.
- Static analysis. A breakdown of your configuration that provides recommendations to improve the performance, security, and reliability of your NGINX‑delivered applications.
Review all the sections of a report for actionable items as follows
- Version and Overview — Look for any surprises and address them.
- Security — Review and address all security advisories, as applicable.
- Virtual servers — Review Virtual servers to see a breakdown of configured servers and, if relevant, SSL/TLS information.
- SSL — Check the status of your SSL certificates and make sure nothing has expired. If you don’t want this analysis in the Reports, disable it in the Settings menu.
- Static analysis — Review and address all warnings as needed.
In this post we learnt how to install and configure amplify agent and showcased how to use dashboard,graphs to analyse the server. Also we learnt how to setup alerts and be the first person to know if there are any issues with server.