Personal tools
You are here: Home Web Reverse Proxy And Cache Nginx Amplify (beta) on CentOS 7
 

Nginx Amplify (beta) on CentOS 7

 

Recommended Install Procedure 

The recommeded install is:

$ curl -sS -L -O https://github.com/nginxinc/nginx-amplify-agent/raw/master/packages/install.sh
# API_KEY='ecfdee2e010899135c258d741a6effc7' sh ./install.sh
# systemctl enable amplify-agent 

There was too much code for various platforms in the code for me to quickly evaluate what it does so I went with the manual install option from the docs.

Manual Installation

Create a repo file: 

# cat >/etc/yum.repos.d/nginx-amplify.repo <<EOF
[nginx-amplify]
name=nginx amplify repo
baseurl=http://packages.amplify.nginx.com/centos/7/\$basearch
gpgcheck=1
gpgkey=http://nginx.org/keys/nginx_signing.key
enabled=1
EOF

Install the agent rpm package:

# yum install nginx-amplify-agent

Copy the sample configuration to '/etc/amplify-agent/agent.conf'. Configure the API key (and hostname) in '/etc/amplify-agent/agent.conf' which should be obtained from the signup email or the amplify.nginx.com web site.

Enable and start the service. This runs as a non-systemd service.

# systemctl enable amplify-agent
# systemctl start amplify-agent

Verify the installtion by inspectivng the log file '/var/log/amplify-agent/agent.log'

Nginx configuration

Checklist:

  1. stub status
  2. extended access logging
  3. 'warn' level on error logging

Ensure that the nginx stub status is enabled:

server {
    listen               [::]:80;
    server_name          violet.lucidsolutions.co.nz localhost [::1] 127.0.0.1;
    keepalive_timeout    70;

    location /nginx_status {
        stub_status;
        access_log  off;

        allow       ::1;
        allow       127.0.0.1;
        deny        all;
    }
}

 

The logging needs to be confiured to have extended information as per the documentation:

    log_format  main     '$remote_addr - $remote_user [$time_local] "$request" '
                         ' $status $body_bytes_sent "$http_referer" '
                         '"$http_user_agent" "$http_x_forwarded_for" '
                         'rt=$request_time ua="$upstream_addr" '
                         'us="$upstream_status" ut="$upstream_response_time" '
                         'ul="$upstream_response_length" '
                         'cs=$upstream_cache_status' ;

Ensure warnings are logged to the error log:

error_log  /var/log/nginx/error.log warn

Issues

  1. The amplify.nginx.com web sites uses HSTS with subdomains. The packages.amplify.nginx.com web site doesn't have https support. Accessing/testing via a web browser is problemtic (it just doesn't work if you have been the the amplify.nginx.com web site). FIXED

Links

 

Appendices

yum install

# yum install nginx-amplify-agent
Resolving Dependencies
--> Running transaction check
---> Package nginx-amplify-agent.x86_64 0:0.30-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================
 Package                        Arch              Version                 Repository                Size
=========================================================================================================
Installing:
 nginx-amplify-agent            x86_64            0.30-1.el7              nginx-amplify            3.4 M

Transaction Summary
=========================================================================================================
Install  1 Package

Total size: 3.4 M
Installed size: 17 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/nginx-amplify/packages/nginx-amplify-agent-0.30-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Retrieving key from http://nginx.org/keys/nginx_signing.key
Importing GPG key 0x7BD9BF62:
 Userid     : "nginx signing key <signing-key@nginx.com>"
 Fingerprint: 573b fd6b 3d8f bc64 1079 a6ab abf5 bd82 7bd9 bf62
 From       : http://nginx.org/keys/nginx_signing.key
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : nginx-amplify-agent-0.30-1.el7.x86_64                                                 1/1
  Verifying  : nginx-amplify-agent-0.30-1.el7.x86_64                                                 1/1

Installed:
  nginx-amplify-agent.x86_64 0:0.30-1.el7

Complete!

Default configuration

The default configuration file '/etc/amplify-agent/agent.conf':

[credentials]
api_key =
hostname =
uuid =

[nginx]
user =
configfile = /etc/nginx/nginx.conf

[proxies]
https =

[cloud]
api_url = https://receiver.amplify.nginx.com:443/1.1
api_timeout = 5.0

[loggers]
keys=root,devnull,agent-default

[handlers]
keys=root,devnull,agent-default

[formatters]
keys=simpleFormatter

[formatter_simpleFormatter]
format=%(asctime)s [%(process)d] %(threadName)s %(message)s
datefmt=

[logger_devnull]
level=DEBUG
qualname=devnull
handlers=devnull
formatter=simpleFormatter
propagate=0

[handler_devnull]
class=logging.handlers.WatchedFileHandler
level=DEBUG
formatter=simpleFormatter
args=('/dev/null',)

[logger_root]
level=DEBUG
handlers=root
qualname=root
formatter=simpleFormatter
propagate=0

[handler_root]
class=logging.handlers.WatchedFileHandler
level=DEBUG
formatter=simpleFormatter
args=('/dev/null',)

[logger_agent-default]
level=INFO
qualname=agent-default
handlers=agent-default
formatter=simpleFormatter
propagate=0

[handler_agent-default]
class=logging.handlers.WatchedFileHandler
level=INFO
formatter=simpleFormatter
args=('/var/log/amplify-agent/agent.log', 'a', None, 1)

RPM Package

The rpm http://packages.amplify.nginx.com/centos/7/x86_64/RPMS/nginx-amplify-agent-0.30-1.el7.x86_64.rpm has the following files:

Name        : nginx-amplify-agent
Version     : 0.30
Release     : 1.el7
Architecture: x86_64
Install Date: (not installed)
Group       : System Environment/Daemons
Size        : 17391632
License     : 2-clause BSD-like license
Signature   : RSA/SHA1, Sat 19 Mar 2016 11:16:50 NZDT, Key ID abf5bd827bd9bf62
Source RPM  : nginx-amplify-agent-0.30-1.el7.src.rpm
Build Date  : Sat 19 Mar 2016 11:13:23 NZDT
Build Host  : centos7-amd64-builder-builder.gnt.nginx.com
Relocations : (not relocatable)
Packager    : Nginx Software, Inc. <https://www.nginx.com>
Vendor      : Nginx Software, Inc.
URL         : https://github.com/nginxinc
Summary     : NGINX Amplify Agent
Description :
The NGINX Amplify Agent is a small, Python application that
provides system and NGINX metric collection. It is part of
NGINX Amplify - the monitoring and configuration assistance
service for NGINX.
This package installs and runs NGINX Amplify Agent daemon.
See http://nginx.com/amplify for more information
* Wed Mar 16 2016 Mike Belov <dedm@nginx.com> 0.30-1
- 0.30-1
- Bug fixes
- Initial SSL analytics support


...


-rw-r--r--    1 root    root                     1121 Mar  9 08:51 /etc/amplify-agent/agent.conf.default
-rwxr-xr-x    1 root    root                     3201 Mar 15 06:22 /etc/init.d/amplify-agent
-rw-r--r--    1 root    root                      122 Mar  9 08:51 /etc/logrotate.d/amplify-agent
-rwxr-xr-x    1 root    root                     2934 Mar 19 11:13 /usr/bin/nginx-amplify-agent.py
drwxr-xr-x    2 root    root                        0 Mar 19 11:13 /usr/lib/python2.7/site-packages/amplify
-rw-r--r--    1 root    root                      309 Mar  9 08:51 /usr/lib/python2.7/site-packages/amplify/__init__.py
-rw-r--r--    2 root    root                      484 Mar 19 11:13 /usr/lib/python2.7/site-packages/amplify/__init__.pyc
-rw-r--r--    2 root    root                      484 Mar 19 11:13 /usr/lib/python2.7/site-packages/amplify/__init__.pyo
drwxr-xr-x    2 root    root                        0 Mar 19 11:13 /usr/lib/python2.7/site-packages/amplify/agent

...


-rw-r--r--    1 root    root                       47 Mar 19 11:12 /usr/lib/python2.7/site-packages/nginx_amplify_agent-0.30-py2.7.egg-info/pbr.json
-rw-r--r--    1 root    root                        8 Mar 19 11:13 /usr/lib/python2.7/site-packages/nginx_amplify_agent-0.30-py2.7.egg-info/top_level.txt
drwxr-xr-x    2 nginx   nginx                       0 Mar 19 11:13 /var/log/amplify-agent
drwxr-xr-x    2 nginx   nginx                       0 Mar 19 11:13 /var/run/amplify-agent

Recommended install log

# curl -sS -L -O https://github.com/nginxinc/nginx-amplify-agent/raw/master/packages/install.sh
# API_KEY='AAAAAAAAAAAAAAAAAAAAAAAAAABBBCCC' sh ./install.sh

 This script will install NGINX Amplify Agent

 1. Checking user ... root, ok.
 2. Checking API key ... using 66a4ac2fd4d4aaeee7b494dfd3c90d10
 3. Checking python version ... found python 2.7
 4. Checking OS compatibility ... centos detected.
 5. Adding public key ... done.
 6. Adding repository config ... added.
 7. Updating repository ...

Loaded plugins: fastestmirror
base                                                     | 3.6 kB     00:00
extras                                                   | 3.4 kB     00:00
nginx                                                    | 2.9 kB     00:00
nginx-amplify                                            | 2.9 kB     00:00
updates                                                  | 3.4 kB     00:00
(1/7): base/7/x86_64/other_db                              | 2.3 MB   00:00
(2/7): extras/7/x86_64/other_db                            | 371 kB   00:00
(3/7): nginx-amplify/x86_64/primary_db                     |  14 kB   00:00
(4/7): nginx/x86_64/other_db                               |  12 kB   00:00
(5/7): nginx-amplify/x86_64/filelists_db                   |  61 kB   00:00
(6/7): nginx-amplify/x86_64/other_db                       | 7.6 kB   00:00
(7/7): updates/7/x86_64/other_db                           |  34 MB   00:02
Loading mirror speeds from cached hostfile
 * base: mirror.xnet.co.nz
 * extras: mirror.xnet.co.nz
 * updates: mirror.xnet.co.nz
Metadata Cache Created

 7. Updating repository ... done.
 8. Installing package ...

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.xnet.co.nz
 * extras: mirror.xnet.co.nz
 * updates: mirror.xnet.co.nz
Resolving Dependencies
--> Running transaction check
---> Package nginx-amplify-agent.x86_64 0:0.32-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                  Arch        Version          Repository          Size
================================================================================
Installing:
 nginx-amplify-agent      x86_64      0.32-1.el7       nginx-amplify      3.5 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 3.5 M
Installed size: 17 M
Is this ok [y/d/N]: y
Downloading packages:
nginx-amplify-agent-0.32-1.el7.x86_64.rpm                  | 3.5 MB   00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : nginx-amplify-agent-0.32-1.el7.x86_64                        1/1
  Verifying  : nginx-amplify-agent-0.32-1.el7.x86_64                        1/1

Installed:
  nginx-amplify-agent.x86_64 0:0.32-1.el7

Complete!

 8. Installing package ... done.
 9. Building configuration file ... done.

 OK, it looks like everything is ready.

 To start and stop the agent type:

     # service amplify-agent start
     # service amplify-agent stop

 Agent logs can be found in:
     /var/log/amplify-agent/agent.log

 Please find the documentation here:
     https://github.com/nginxinc/nginx-amplify-doc

 After the agent is launched, it might take up to 1 minute
 for this system to appear in the Amplify user interface.

 Launching amplify-agent ...
 All done.
Document Actions