Part Two: How to Monitor Nginx using Elastic Stack on a CentOS 7 VPS or Dedicated Server

In the previous article (Part One: How to Monitor Nginx using Elastic Stack on a CentOS 7 VPS or Dedicated Server) you learned how to install the various component of the Elastic Stack Next, we will help you use the installed components to monitor Nginx web server.

Ready? Let’s go!

Create and use visualizations

From this point, we’ll only use the Kibana browser-based windows to view and search the system data.

Filebeat is already monitoring the NGINX access as well as the error logs. However, we must generate traffic to create data that can be visualized in Kibana. Run the command below in a separate window to create web server requests:

while true ; do n=$(( RANDOM % 10 )) ; curl "localhost/?$n" ; sleep $n ; done

In your browser, navigate to http://localhost:5601 to access the secure port where you can open Kibana.

On the left sidebar, select your default index pattern to direct Kibana to utilize the docs indexed by either Metricbeat or Filebeat. Select filebeat-* to view the index pattern of Filebeat, then from the screen below, choose the start icon, to set filebeat-*as your default index pattern.

Next, click on “discover” to view the logs indexed by Filebeat. The window below will appear:

In the search box enter nginx.access.url:”/?5″. This will enable you to search all NGINX access logs for requests that correspond to /?5. The logs represent those that are created by the shell loop running in the background. An Elasticsearch will be conducted automatically by the interface to display all the matching documents.

Filebeats’ Dshboards

>Besides gathering NGINX access logs, Filebeats presents numerous dashboards into the Kibana service to deliver vital default visualization for data. Select “Dashboard” from the left sidebar menu:

A list of all the dashboards on Kibana will appear:

Enter “nginx” in the search box to search the NGINX dashboards. Select all the dashboards with the title “[Filebeat Nginx] Access and error logs”. The Windows below will appear:

Keep scrolling down to see all the visualizations present in the default dashboard. Some of the visualizations of interest include response code by URL, geolocation maps, and useragent summaries. The dashboards makes it easy to analyze the traffic to your webserver and debug issues.

First, navigate to the “Response codes over time” display in the default dashboard. There should be numerous 404 responses there, click on any of the 404 bars.

At the top of the Kibana dashboard click on “Apply Now” to filter all the access logs that gave a 404 response to the user. The window below will appear:

Now scroll down to access the visualization for the 404 logs. The “Response codes by top URLs” interfaces show NGINX is only giving 404 response codes that correspond to /server-status url:

It now easy to fix NGINX configuration and resolve the error.

Configuring Nginx

Access the /etc/nginx/nginx.conf file and add a location data between the include line and location line.


include /etc/nginx/default.d/*.conf;

    location /server-status {
            stub_status on
            access_log off;
            allow ::1;
            deny all;

    location / {

Run the command below to restart NGINX:

sudo systemctl restart nginx

Now, repeat the steps in the previous section to view the response code history. The 404 codes should slowly stop appearing, as you conduct new searches on Kibana.


Using the visualizations generated by Metricbeat it easy to see not only the web server logs but also the host metrics.

Choose the dashboard from the sidebar, then in the search box type “metricbeat” to filter the Mtericbeat dashboards. Select the dashboard titled “[Metricbeat System] Overview”.  The following window will appear:

The dashboard above features a comprehensive overview of the host metrics including memory, CPU, network use, and disk. Navigate to the “System Navigation” area and select the “Host Overview”.

Scroll down to see the host data collected by Metricbeat. The following windows will appear.

The above window provides a wealth of data of the machine metrics gathered by Metricbeat.


This tutorial covered only a part of the information provided by Metricbeat and Filebeat for search and analysis. You can generate other visualization to provide specific solutions and helpful dashboards for numerous purposes. Search for more comprehensive guides for each component of the stack to get additional information regarding the use of the additional dashboards and visualizations.

Special Note: some leading web hosts provide free 1-click installations of other tools for monitoring server performance. At Hostadvice, you can find extensive information the hosting plans and what they include, as well as user and expert reviews on the best web hosting services.

Check out these top 3 Best web hosting services

Was this article helpful?