How to Use Datadog to monitor Nginx (part 3)

Source: Internet
Author: User
Tags nginx host datadog

How to Use Datadog to monitor Nginx (part 3)

If you have read the previous sections on how to monitor NGINX, you should know how much information you can get from several metrics of your network environment. You can also see how easy it is to collect metrics from a specific NGINX base. However, to achieve comprehensive and continuous monitoring of NGINX, you need a powerful monitoring system to store and visualize metrics. You can be reminded when exceptions occur. In this article, we will show you how to use Datadog to install NGINX monitoring so that you can view these metrics in a custom dashboard:

NGINX dashboard

Datadog allows you to build graphs and warnings with a single host, service, process, and measurement, or use almost any combination of them for building. For example, you can monitor all your hosts, or all NGINX hosts in a specific zone, or you can monitor a key indicator of all hosts with specific tags. This article will show you how:

  • Monitor NGINX metrics on the Datadog dashboard, just like monitoring other systems
  • Set an automatic alarm to notify you of sharp changes to a key indicator

 

Configure NGINX

To collect NGINX metrics, you must first make sure that the status module is enabled and a URL that reports the status metrics. For step-by-step configuration of open-source NGINX and NGINX Plus, see previous articles.

 

Integrate Datadog and NGINX

 

Install the Datadog agent

The Datadog agent is an open-source software that collects and reports metrics of your host so that you can use Datadog to view and monitor them. To install this proxy, you usually only need one command.

As long as your agent is started and running, you will see that your host's metric report is under your Datadog account.

Datadog infrastructure list

 

Configure the Agent

Next, you need to create a simple NGINX configuration file for the proxy. The proxy configuration directory in your system should be found here.

In the conf. d/nginx. yaml. example directory, you will find a simple configuration file. You can edit and provide the status URL and optional labels for each NGINX instance:

  1. init_config:
  2. instances:
  3. - nginx_status_url: http://localhost/nginx_status/
  4. tags:
  5. - instance:foo

When you provide the status URL and any tag, save the configuration file as conf. d/nginx. yaml.

 

Restart proxy

You must restart the agent to load the new configuration file. Here, the restart command varies depending on the platform.

 

Check the configuration file

Check whether Datadog and NGINX are correctly integrated and run the info command of Datadog. The commands used by each platform can be viewed here.

If the configuration is correct, you will see the following output:

  1. Checks
  2. ======
  3. [...]
  4. nginx
  5. -----
  6. - instance #0 [OK]
  7. -Collected8 metrics &0 events

 

Installation and integration

Finally, enable "Nginx integration" in your Datadog account ". This is very simple. You only need to click "Install Integration" in NGINX Integration settings.

Install integration

 

Metric!

Once the agent starts reporting NGINX metrics, you will see an NGINX dashboard appear in the list of available Dashboard of your Datadog.

The basic NGINX dashboard displays useful charts, including several key metrics in our NGINX monitoring introduction. (Some metrics, especially the request processing time, require log analysis, which is not supported by Datadog .)

You can easily create a comprehensive dashboard by adding charts with important metrics outside NGINX to monitor your entire website. For example, you may want to monitor your NGINX host-level metrics, such as system load. To create a custom dashboard, click the option near the upper-right corner of the dashboard and select "Clone Dash" to Clone a default NGINX dashboard.

Clone dash

You can also use the Datadog host map to monitor your NGINX instance at a higher level. For example, you can use the color to indicate the CPU usage of all your NGINX hosts to identify potential hot spots.

 

NGINX metric warning

Once Datadog captures and visualizes your metrics, you may want to establish some monitoring to automatically pay close attention to your metrics and remind you of any problems. The following is a typical example: An indicator monitor that reminds you of sudden drops in NGINX throughput.

 

Monitor NGINX Throughput

The Datadog metric alert can be a "Throughput-based" metric that alerts you when the metric exceeds the set value) or a "change range-based" metric that alerts you when the metric changes beyond a certain range ). In this example, we will adopt the next method. When the number of incoming requests per second drops sharply, we will be reminded. Downgrading often implies problems.

  1. Create a new metric monitoring. Select "New Monitor" from the "Monitors" drop-down list of Datadog ". Select Metric as the monitor type.

    NGINX metric monitor

  2. Define Your metric monitor. We want to know the total number of requests per second in NGINX, So we define the nginx.net. request that we are interested in the infrastructure.PerS.

    NGINX metric

  3. Set metric alarm conditions. We want to Alert when the Change is not a fixed value, so we select "Change Alert ". We set the alarm to whenever the Request volume drops by more than 30%. Here, we use a one-minute data window to represent the value of the "now" indicator, and compare the average variation across this interval with the indicator value of the previous 10 minutes.

    NGINX metric change alert

  4. Custom notifications. If NGINX requests decrease, we want to notify our team. In this example, we will send a notification to the ops team's chat room and send a text message to the engineer on duty. In "Say what's happening", we will name the monitor and add a short message with the notification. We recommend that you start the investigation first. We will @ the Slack used by the ops team and @ pagerduty will send a warning to the text message.

    NGINX metric notification

  5. Save Integrated Monitoring. Click "Save" at the bottom of the page. You are currently monitoring a key NGINX indicator, and when it rapidly drops, it will send a text message to the engineer on duty.

 

Conclusion

In this article, we talked about how to integrate NGINX and Datadog to visualize your key metrics and notify your team when your network infrastructure is faulty.

If you have been using your own Datadog account, you should be able to greatly improve the visualization of your web environment, it also has the ability to automatically monitor your environment, the mode you use, and the most valuable metrics in your organization.

If you do not have a Datadog account, you can register for a free trial and start to monitor your infrastructure, applications, and current services.

For more Nginx tutorials, see the following:

Deployment of Nginx + MySQL + PHP in CentOS 6.2

Build a WEB server using Nginx

Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5

Performance Tuning for Nginx in CentOS 6.3

Configure Nginx to load the ngx_pagespeed module in CentOS 6.3

Install and configure Nginx + Pcre + php-fpm in CentOS 6.4

Nginx installation and configuration instructions

Nginx log filtering using ngx_log_if does not record specific logs

Nginx details: click here
Nginx: click here

Via: https://www.datadoghq.com/blog/how-to-monitor-nginx-with-datadog/

Author: K Young Translator: strugglingyouth Proofreader: wxy

This article was originally translated by LCTT and launched with the Linux honor in China

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.