amplify color_如何使用Amplify监视Nginx

amplify color

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

Amplify是一个功能强大,轻巧且直观的基于SaaS的监视平台,用于监视Nginx和Nginx Plus。 它监视并显示Nginx指标,例如

  1. Current connections

    当前连接
  2. Current requests

    当前请求
  3. HTTP errors

    HTTP错误
  4. HTTP version

    HTTP版本
  5. Nginx memory usage

    Nginx内存使用情况
  6. Nginx CPU usage

    Nginx CPU使用率
  7. Nginx traffic

    Nginx流量

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.

此外,它还监视操作系统的指标,例如CPU使用率,平均负载,内存使用率,网络流量和交换空间。 在本指南中,我们将学习如何使用Amplify监控SaaS平台来监控Nginx。

先决条件 (Prerequisites)

  1. An instance of Nginx installed on a server. Recommended Read: Install Nginx on Ubuntu 18.04

    服务器上安装的Nginx实例。 推荐阅读: 在Ubuntu 18.04上安装Nginx
  2. SSH access to the server. Recommended Read: SSH Command in Linux

    SSH访问服务器。 推荐阅读: Linux中的SSH命令

In this guide, we have an instance of Nginx installed on a CentOS 7 server system (Hostname: spikey).

在本指南中,我们在CentOS 7服务器系统(主机名:spikey)上安装了Nginx实例。

Let’s jump right in and see how we can monitor Nginx with Amplify.

让我们直接进入,看看如何使用Amplify监视Nginx。

步骤1:在Nginx 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.

首先,您需要创建一个帐户以开始配置。 单击此链接在Amplify网站中创建一个帐户。

Thereafter, you will receive an email notification with a confirmation link. Click on the link to Sign in to Amplify.

此后,您将收到带有确认链接的电子邮件通知。 单击链接以登录以放大。

步骤2:下载Amplify Install脚本 (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.

登录后,将显示以下页面以及说明。 首先,将通过SSH登录到您的服务器。

The next step will be to download the install script using either curl or wget command:

下一步将使用curlwget命令下载安装脚本:

# wget https://github.com/nginxinc/nginx-amplify-agent/raw/master/packages/install.sh

Sample Output

样本输出

步骤3:安装Amplify Agent套件 (Step 3: Install the Amplify Agent Package)

Next, run the second command to install Amplify Agent package

接下来,运行第二个命令以安装Amplify Agent软件包

# 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.

成功安装Amplify代理程序包后,服务器将在Amplify上列出,并且指标将开始收集。

Hit the ‘Continue’ button to go to the next step.

点击“继续”按钮转到下一步。

步骤4:配置Nginx以可视化关键指标 (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

下一页将显示另一组说明,如下所示。 将您当前的工作目录更改为/etc/nginx

# cd /etc/nginx

Next, verify that conf.d files are automatically added in Nginx configuration

接下来,确认conf.d文件已自动添加到Nginx配置中

grep -i include\.*conf nginx.conf

Next, create a new file called stub_status.conf

接下来,创建一个名为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

验证是否已添加stub_status.conf文件

Sample Output

样本输出

Next, run the command below to reload Nginx for the stub_status module to become active.

接下来,运行以下命令重新加载Nginx,以使stub_status模块变为活动状态。

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

Click on the ‘Continue’ button to proceed to the Next page.

单击“继续”按钮进入下一页。

步骤5:修改nginx.conf文件 (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

最后一步将需要修改/etc/nginx/nginx.conf文件。 我们将专门对3个部分进行调整

error_log

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
如图所示编辑此属性

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

log_format

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.

重新加载Nginx并单击“完成”按钮。

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’

要更全面地了解您的Nginx应用程序,请单击“概述”

Thank you for coming this far. Feel free to send your feedback in the comments sections below.

谢谢你走这么远。 欢迎在下面的评论部分中发送您的反馈。

翻译自: https://www.journaldev.com/29166/monitor-nginx-amplify

amplify color

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值