Giter VIP home page Giter VIP logo

docker-nginx-amplify's Introduction

1. Overview

NGINX Amplify is a free monitoring tool that can be used with a microservice architecture based on NGINX and Docker. Amplify is developed and maintained by Nginx Inc. — the company behind the NGINX software.

With Amplify it is possible to collect and aggregate metrics across Docker containers, and present a coherent set of visualizations of the key NGINX performance data, such as active connections or requests per second. It is also easy to quickly check for any performance degradations, traffic anomalies, and get a deeper insight into the NGINX configuration in general.

In order to use Amplify, a small Python-based agent software Amplify Agent should be installed inside the container.

The official documentation for Amplify is available here.

1.1. NGINX Amplify Agent Inside Docker Container

The Amplify Agent can be deployed in a Docker environment to monitor NGINX instances inside Docker containers.

The "agent-inside-the-container" is currenly the only mode of operation. In other words, the agent should be running in the same container, next to the NGINX instance.

1.2. Standalone Mode

By default the agent will try to determine the OS hostname on startup (see the docs here for more information). The hostname is used to generate an UUID to uniquely identify the new object in the monitoring backend.

This means that in the absence of the additional configuration steps, each new container started from an Amplify-enabled Docker image will be reported as a standalone system in the Amplify web user interface. Moreover, the reported hostname is typically something not easily readable.

When using Amplify with Docker, another option is available and recommended — which is imagename. The imagename option tells the Amplify Agent that it's running in a container environment, and that the agent should collect and report metrics and metadata accordingly.

If you prefer to see the individual instances started from the same image as separate objects, assign different imagename to each of the running instances.

You can learn more about the agent configuration options here.

1.3. Aggregate Mode

As described above, when reporting a new object for monitoring, the agent honors the imagename configuration option in the /etc/amplify-agent/agent.conf file.

The imagename option should be set either in the Dockerfile or using the environment variables.

It is possible to explicitly specify the same imagename for multiple instances. In this scenario, the metrics received from several agents will be aggregated internally on the backend side — with a single 'container'-type object created for monitoring.

This way a combined view of various statistics can be obtained (e.g. for a "microservice"). For example, this combined view can display the total number of requests per second through all backend instances of a microservice.

Containers with a common imagename do not have to share the same local Docker image or NGINX configuration. They can be located on different physical hosts too.

To set a common imagename for several containers started from the Amplify-enabled image, you may either:

  • Configure it explicitly in the Dockerfile
# If AMPLIFY_IMAGENAME is set, the startup wrapper script will use it to
# generate the 'imagename' to put in the /etc/amplify-agent/agent.conf
# If several instances use the same 'imagename', the metrics will
# be aggregated into a single object in NGINX Amplify. Otherwise Amplify
# will create separate objects for monitoring (an object per instance).
# AMPLIFY_IMAGENAME can also be passed to the instance at runtime as
# described below.

ENV AMPLIFY_IMAGENAME my-docker-instance-123

or

  • Use the -e option with docker run as in
docker run --name mynginx1 -e API_KEY=ffeedd0102030405060708 -e AMPLIFY_IMAGENAME=my-service-123 -d nginx-amplify

1.4. Current Limitations

The following list summarizes existing limitations of monitoring Docker containers with Amplify:

  • In order for the agent to collect additional NGINX metrics the NGINX logs should be kept inside the container (by default the NGINX logs are redirected to the Docker log collector). Alternatively the NGINX logs can be fed to the agent via syslog.
  • In "aggregate" mode, some of the OS metrics and metadata are not collected (e.g. hostnames, CPU usage, Disk I/O metrics, network interface configuration).
  • The agent can only monitor NGINX from inside the container. It is not currently possible to run the agent in a separate container and monitor the neighboring containers running NGINX.

We've been working on improving the support for Docker even more. Stay tuned!

2. How to Build and Run an Amplify-enabled NGINX image?

2.1. Building an Amplify-enabled image with NGINX

(Note: If you are really new to Docker, here's how to install Docker Engine on various OS.)

Let's pick our official NGINX Docker image as a good example. The Dockerfile that we're going to use for an Amplify-enabled image is part of this repo.

Here's how you can build the Docker image with the Amplify Agent inside, based on the official NGINX image:

git clone https://github.com/nginxinc/docker-nginx-amplify.git
cd docker-nginx-amplify
docker build -t nginx-amplify .

After the image is built, check the list of Docker images:

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx-amplify       latest              d039b39d2987        3 minutes ago       241.6 MB

2.2. Running an Amplify-enabled NGINX Docker Container

Unless already done, you have to sign up, create an account in NGINX Amplify, and obtain a valid API_KEY.

To start a container from the new image, use the command below:

docker run --name mynginx1 -e API_KEY=ffeedd0102030405060708 -e AMPLIFY_IMAGENAME=my-service-123 -d nginx-amplify

where the API_KEY is that assigned to your NGINX Amplify account, and the AMPLIFY_IMAGENAME is set to identify the running service as described in sections 1.2 and 1.3 above.

After the container has started, you may check its status with docker ps:

docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
7d7b47ba4c72        nginx-amplify       "/entrypoint.sh"    3 seconds ago       Up 2 seconds        80/tcp, 443/tcp     mynginx1

and you can also check docker logs:

docker logs 7d7b47ba4c72
starting nginx ...
updating /etc/amplify-agent/agent.conf ...
---> using api_key = ffeedd0102030405060708
---> using imagename = my-service-123
starting amplify-agent ...

Check what processes have started:

docker exec 7d7b47ba4c72 ps axu
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1   4328   676 ?        Ss   19:33   0:00 /bin/sh /entrypoint.sh
root         5  0.0  0.5  31596  2832 ?        S    19:33   0:00 nginx: master process nginx -g daemon off;
nginx       11  0.0  0.3  31988  1968 ?        S    19:33   0:00 nginx: worker process
nginx       65  0.6  9.1 111584 45884 ?        S    19:33   0:06 amplify-agent

If you see the amplify-agent process, it all went smoothly, and you should see the new container in the Amplify web user interface in about a minute or so.

Check the Amplify Agent log:

docker exec 7d7b47ba4c72 tail /var/log/amplify-agent/agent.log
2016-08-05 19:49:39,001 [65] supervisor agent started, version=0.37-1 pid=65 uuid=<..> imagename=my-service-123
2016-08-05 19:49:39,047 [65] nginx_config running nginx -t -c /etc/nginx/nginx.conf
2016-08-05 19:49:40,047 [65] supervisor post https://receiver.amplify.nginx.com:443/<..>/ffeedd0102030405060708/agent/ 200 85 4 0.096
2016-08-05 19:50:24,674 [65] bridge_manager post https://receiver.amplify.nginx.com:443/<..>/ffeedd0102030405060708/update/ 202 2370 0 0.084

When you're done with the container, you can stop it like the following:

docker stop 7d7b47ba4c72

To check the status of all containers (running and stopped):

docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                        PORTS               NAMES
7d7b47ba4c72        nginx-amplify       "/entrypoint.sh"         22 minutes ago      Exited (137) 19 seconds ago                       mynginx1

Happy monitoring, and feel free to send us questions, opinions, and any feedback in general.

docker-nginx-amplify's People

Contributors

cdarwin avatar defanator avatar dwmcallister avatar gdzien avatar mikhailov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-nginx-amplify's Issues

Build fails on macOS host

Hi,
I'm trying to build the image by following the guide but it fails on:

The command '/bin/sh -c apt-get update     && apt-get install -qqy curl python apt-transport-https apt-utils gnupg1 procps     && echo 'deb https://packages.amplify.nginx.com/debian/ stretch amplify-agent' > /etc/apt/sources.list.d/nginx-amplify.list     && curl -fs https://nginx.org/keys/nginx_signing.key | apt-key add - > /dev/null 2>&1     && apt-get update     && apt-get install -qqy nginx-amplify-agent     && apt-get purge -qqy curl apt-transport-https apt-utils gnupg1     && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 2

Versions:

Docker version 17.12.0-ce, build c97c6d6

macOS High Sierra: 10.13.3

It look similar to the #6 but it's from 2016 so I open a new one :)

I tried on a Ubuntu host (running in a vm on the same machine) where it builds fine so it does not seem to be an network issue

Full log:

docker build -t nginx-amplify .
Sending build context to Docker daemon  202.8kB
Step 1/7 : FROM nginx:1.13
 ---> e548f1a579cf
Step 2/7 : MAINTAINER NGINX Amplify Engineering
 ---> Using cache
 ---> 4d65c0821122
Step 3/7 : RUN apt-get update     && apt-get install -qqy curl python apt-transport-https apt-utils gnupg1 procps     && echo 'deb https://packages.amplify.nginx.com/debian/ stretch amplify-agent' > /etc/apt/sources.list.d/nginx-amplify.list     && curl -fs https://nginx.org/keys/nginx_signing.key | apt-key add - > /dev/null 2>&1     && apt-get update     && apt-get install -qqy nginx-amplify-agent     && apt-get purge -qqy curl apt-transport-https apt-utils gnupg1     && rm -rf /var/lib/apt/lists/*
 ---> Running in 4d57cd9ea754
Get:1 http://security.debian.org stretch/updates InRelease [63.0 kB]
Ign:2 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:4 http://security.debian.org stretch/updates/main amd64 Packages [415 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages [8431 B]
Get:7 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]
Get:8 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [9531 kB]
Fetched 10.2 MB in 2s (4374 kB/s)
Reading package lists...
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpython2.7-minimal:amd64.
(Reading database ... 7027 files and directories currently installed.)
Preparing to unpack .../00-libpython2.7-minimal_2.7.13-2+deb9u2_amd64.deb ...
Unpacking libpython2.7-minimal:amd64 (2.7.13-2+deb9u2) ...
Selecting previously unselected package python2.7-minimal.
Preparing to unpack .../01-python2.7-minimal_2.7.13-2+deb9u2_amd64.deb ...
Unpacking python2.7-minimal (2.7.13-2+deb9u2) ...
Selecting previously unselected package python-minimal.
Preparing to unpack .../02-python-minimal_2.7.13-2_amd64.deb ...
Unpacking python-minimal (2.7.13-2) ...
Selecting previously unselected package mime-support.
Preparing to unpack .../03-mime-support_3.60_all.deb ...
Unpacking mime-support (3.60) ...
Selecting previously unselected package libffi6:amd64.
Preparing to unpack .../04-libffi6_3.2.1-6_amd64.deb ...
Unpacking libffi6:amd64 (3.2.1-6) ...
Selecting previously unselected package readline-common.
Preparing to unpack .../05-readline-common_7.0-3_all.deb ...
Unpacking readline-common (7.0-3) ...
Selecting previously unselected package libreadline7:amd64.
Preparing to unpack .../06-libreadline7_7.0-3_amd64.deb ...
Unpacking libreadline7:amd64 (7.0-3) ...
Selecting previously unselected package libsqlite3-0:amd64.
Preparing to unpack .../07-libsqlite3-0_3.16.2-5+deb9u1_amd64.deb ...
Unpacking libsqlite3-0:amd64 (3.16.2-5+deb9u1) ...
Selecting previously unselected package libpython2.7-stdlib:amd64.
Preparing to unpack .../08-libpython2.7-stdlib_2.7.13-2+deb9u2_amd64.deb ...
Unpacking libpython2.7-stdlib:amd64 (2.7.13-2+deb9u2) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../09-python2.7_2.7.13-2+deb9u2_amd64.deb ...
Unpacking python2.7 (2.7.13-2+deb9u2) ...
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../10-libpython-stdlib_2.7.13-2_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.13-2) ...
Setting up libpython2.7-minimal:amd64 (2.7.13-2+deb9u2) ...
Setting up python2.7-minimal (2.7.13-2+deb9u2) ...
Linking and byte-compiling packages for runtime python2.7...
Setting up python-minimal (2.7.13-2) ...
Selecting previously unselected package python.
(Reading database ... 7836 files and directories currently installed.)
Preparing to unpack .../00-python_2.7.13-2_amd64.deb ...
Unpacking python (2.7.13-2) ...
Selecting previously unselected package libapt-inst2.0:amd64.
Preparing to unpack .../01-libapt-inst2.0_1.4.8_amd64.deb ...
Unpacking libapt-inst2.0:amd64 (1.4.8) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../02-apt-utils_1.4.8_amd64.deb ...
Unpacking apt-utils (1.4.8) ...
Selecting previously unselected package libprocps6:amd64.
Preparing to unpack .../03-libprocps6_2%3a3.3.12-3_amd64.deb ...
Unpacking libprocps6:amd64 (2:3.3.12-3) ...
Selecting previously unselected package libssl1.0.2:amd64.
Preparing to unpack .../04-libssl1.0.2_1.0.2l-2+deb9u2_amd64.deb ...
Unpacking libssl1.0.2:amd64 (1.0.2l-2+deb9u2) ...
Selecting previously unselected package procps.
Preparing to unpack .../05-procps_2%3a3.3.12-3_amd64.deb ...
Unpacking procps (2:3.3.12-3) ...
Selecting previously unselected package bzip2.
Preparing to unpack .../06-bzip2_1.0.6-8.1_amd64.deb ...
Unpacking bzip2 (1.0.6-8.1) ...
Selecting previously unselected package libmagic-mgc.
Preparing to unpack .../07-libmagic-mgc_1%3a5.30-1+deb9u1_amd64.deb ...
Unpacking libmagic-mgc (1:5.30-1+deb9u1) ...
Selecting previously unselected package libmagic1:amd64.
Preparing to unpack .../08-libmagic1_1%3a5.30-1+deb9u1_amd64.deb ...
Unpacking libmagic1:amd64 (1:5.30-1+deb9u1) ...
Selecting previously unselected package file.
Preparing to unpack .../09-file_1%3a5.30-1+deb9u1_amd64.deb ...
Unpacking file (1:5.30-1+deb9u1) ...
Selecting previously unselected package krb5-locales.
Preparing to unpack .../10-krb5-locales_1.15-1+deb9u1_all.deb ...
Unpacking krb5-locales (1.15-1+deb9u1) ...
Selecting previously unselected package libgmp10:amd64.
Preparing to unpack .../11-libgmp10_2%3a6.1.2+dfsg-1_amd64.deb ...
Unpacking libgmp10:amd64 (2:6.1.2+dfsg-1) ...
Selecting previously unselected package libnettle6:amd64.
Preparing to unpack .../12-libnettle6_3.3-1+b2_amd64.deb ...
Unpacking libnettle6:amd64 (3.3-1+b2) ...
Selecting previously unselected package libhogweed4:amd64.
Preparing to unpack .../13-libhogweed4_3.3-1+b2_amd64.deb ...
Unpacking libhogweed4:amd64 (3.3-1+b2) ...
Selecting previously unselected package libidn11:amd64.
Preparing to unpack .../14-libidn11_1.33-1_amd64.deb ...
Unpacking libidn11:amd64 (1.33-1) ...
Selecting previously unselected package libp11-kit0:amd64.
Preparing to unpack .../15-libp11-kit0_0.23.3-2_amd64.deb ...
Unpacking libp11-kit0:amd64 (0.23.3-2) ...
Selecting previously unselected package libtasn1-6:amd64.
Preparing to unpack .../16-libtasn1-6_4.10-1.1+deb9u1_amd64.deb ...
Unpacking libtasn1-6:amd64 (4.10-1.1+deb9u1) ...
Selecting previously unselected package libgnutls30:amd64.
Preparing to unpack .../17-libgnutls30_3.5.8-5+deb9u3_amd64.deb ...
Unpacking libgnutls30:amd64 (3.5.8-5+deb9u3) ...
Selecting previously unselected package libkeyutils1:amd64.
Preparing to unpack .../18-libkeyutils1_1.5.9-9_amd64.deb ...
Unpacking libkeyutils1:amd64 (1.5.9-9) ...
Selecting previously unselected package libkrb5support0:amd64.
Preparing to unpack .../19-libkrb5support0_1.15-1+deb9u1_amd64.deb ...
Unpacking libkrb5support0:amd64 (1.15-1+deb9u1) ...
Selecting previously unselected package libk5crypto3:amd64.
Preparing to unpack .../20-libk5crypto3_1.15-1+deb9u1_amd64.deb ...
Unpacking libk5crypto3:amd64 (1.15-1+deb9u1) ...
Selecting previously unselected package libkrb5-3:amd64.
Preparing to unpack .../21-libkrb5-3_1.15-1+deb9u1_amd64.deb ...
Unpacking libkrb5-3:amd64 (1.15-1+deb9u1) ...
Selecting previously unselected package libgssapi-krb5-2:amd64.
Preparing to unpack .../22-libgssapi-krb5-2_1.15-1+deb9u1_amd64.deb ...
Unpacking libgssapi-krb5-2:amd64 (1.15-1+deb9u1) ...
Selecting previously unselected package libsasl2-modules-db:amd64.
Preparing to unpack .../23-libsasl2-modules-db_2.1.27~101-g0780600+dfsg-3_amd64.deb ...
Unpacking libsasl2-modules-db:amd64 (2.1.27~101-g0780600+dfsg-3) ...
Selecting previously unselected package libsasl2-2:amd64.
Preparing to unpack .../24-libsasl2-2_2.1.27~101-g0780600+dfsg-3_amd64.deb ...
Unpacking libsasl2-2:amd64 (2.1.27~101-g0780600+dfsg-3) ...
Selecting previously unselected package libldap-common.
Preparing to unpack .../25-libldap-common_2.4.44+dfsg-5+deb9u1_all.deb ...
Unpacking libldap-common (2.4.44+dfsg-5+deb9u1) ...
Selecting previously unselected package libldap-2.4-2:amd64.
Preparing to unpack .../26-libldap-2.4-2_2.4.44+dfsg-5+deb9u1_amd64.deb ...
Unpacking libldap-2.4-2:amd64 (2.4.44+dfsg-5+deb9u1) ...
Selecting previously unselected package xz-utils.
Preparing to unpack .../27-xz-utils_5.2.2-1.2+b1_amd64.deb ...
Unpacking xz-utils (5.2.2-1.2+b1) ...
Selecting previously unselected package libunistring0:amd64.
Preparing to unpack .../28-libunistring0_0.9.6+really0.9.3-0.1_amd64.deb ...
Unpacking libunistring0:amd64 (0.9.6+really0.9.3-0.1) ...
Selecting previously unselected package libidn2-0:amd64.
Preparing to unpack .../29-libidn2-0_0.16-1+deb9u1_amd64.deb ...
Unpacking libidn2-0:amd64 (0.16-1+deb9u1) ...
Selecting previously unselected package libnghttp2-14:amd64.
Preparing to unpack .../30-libnghttp2-14_1.18.1-1_amd64.deb ...
Unpacking libnghttp2-14:amd64 (1.18.1-1) ...
Selecting previously unselected package libpsl5:amd64.
Preparing to unpack .../31-libpsl5_0.17.0-3_amd64.deb ...
Unpacking libpsl5:amd64 (0.17.0-3) ...
Selecting previously unselected package librtmp1:amd64.
Preparing to unpack .../32-librtmp1_2.4+20151223.gitfa8646d.1-1+b1_amd64.deb ...
Unpacking librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1+b1) ...
Selecting previously unselected package libssh2-1:amd64.
Preparing to unpack .../33-libssh2-1_1.7.0-1_amd64.deb ...
Unpacking libssh2-1:amd64 (1.7.0-1) ...
Selecting previously unselected package libcurl3-gnutls:amd64.
Preparing to unpack .../34-libcurl3-gnutls_7.52.1-5+deb9u4_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (7.52.1-5+deb9u4) ...
Selecting previously unselected package apt-transport-https.
Preparing to unpack .../35-apt-transport-https_1.4.8_amd64.deb ...
Unpacking apt-transport-https (1.4.8) ...
Selecting previously unselected package openssl.
Preparing to unpack .../36-openssl_1.1.0f-3+deb9u1_amd64.deb ...
Unpacking openssl (1.1.0f-3+deb9u1) ...
Selecting previously unselected package ca-certificates.
Preparing to unpack .../37-ca-certificates_20161130+nmu1_all.deb ...
Unpacking ca-certificates (20161130+nmu1) ...
Selecting previously unselected package libcurl3:amd64.
Preparing to unpack .../38-libcurl3_7.52.1-5+deb9u4_amd64.deb ...
Unpacking libcurl3:amd64 (7.52.1-5+deb9u4) ...
Selecting previously unselected package curl.
Preparing to unpack .../39-curl_7.52.1-5+deb9u4_amd64.deb ...
Unpacking curl (7.52.1-5+deb9u4) ...
Selecting previously unselected package libsasl2-modules:amd64.
Preparing to unpack .../40-libsasl2-modules_2.1.27~101-g0780600+dfsg-3_amd64.deb ...
Unpacking libsasl2-modules:amd64 (2.1.27~101-g0780600+dfsg-3) ...
Selecting previously unselected package psmisc.
Preparing to unpack .../41-psmisc_22.21-2.1+b2_amd64.deb ...
Unpacking psmisc (22.21-2.1+b2) ...
Selecting previously unselected package gnupg1.
Preparing to unpack .../42-gnupg1_1.4.21-4_amd64.deb ...
Unpacking gnupg1 (1.4.21-4) ...
Selecting previously unselected package gnupg1-curl.
Preparing to unpack .../43-gnupg1-curl_1.4.21-4_amd64.deb ...
Adding 'diversion of /usr/lib/gnupg1/gpgkeys_curl to /usr/lib/gnupg1/gpgkeys_curl.non_curl by gnupg1-curl'
Adding 'diversion of /usr/lib/gnupg1/gpgkeys_hkp to /usr/lib/gnupg1/gpgkeys_hkp.non_curl by gnupg1-curl'
Unpacking gnupg1-curl (1.4.21-4) ...
Selecting previously unselected package gnupg1-l10n.
Preparing to unpack .../44-gnupg1-l10n_1.4.21-4_all.deb ...
Unpacking gnupg1-l10n (1.4.21-4) ...
Selecting previously unselected package publicsuffix.
Preparing to unpack .../45-publicsuffix_20171028.2055-0+deb9u1_all.deb ...
Unpacking publicsuffix (20171028.2055-0+deb9u1) ...
Setting up readline-common (7.0-3) ...
Setting up libapt-inst2.0:amd64 (1.4.8) ...
Setting up libnettle6:amd64 (3.3-1+b2) ...
Setting up psmisc (22.21-2.1+b2) ...
Setting up libnghttp2-14:amd64 (1.18.1-1) ...
Setting up mime-support (3.60) ...
Setting up libldap-common (2.4.44+dfsg-5+deb9u1) ...
Setting up apt-utils (1.4.8) ...
Setting up libreadline7:amd64 (7.0-3) ...
Setting up libsasl2-modules-db:amd64 (2.1.27~101-g0780600+dfsg-3) ...
Setting up libsasl2-2:amd64 (2.1.27~101-g0780600+dfsg-3) ...
Setting up gnupg1 (1.4.21-4) ...
Setting up gnupg1-l10n (1.4.21-4) ...
Setting up libprocps6:amd64 (2:3.3.12-3) ...
Setting up libtasn1-6:amd64 (4.10-1.1+deb9u1) ...
Setting up libmagic-mgc (1:5.30-1+deb9u1) ...
Setting up bzip2 (1.0.6-8.1) ...
Setting up libmagic1:amd64 (1:5.30-1+deb9u1) ...
Setting up procps (2:3.3.12-3) ...
update-alternatives: using /usr/bin/w.procps to provide /usr/bin/w (w) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/w.1.gz because associated file /usr/share/man/man1/w.procps.1.gz (of link group w) doesn't exist
Setting up libssl1.0.2:amd64 (1.0.2l-2+deb9u2) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up libgmp10:amd64 (2:6.1.2+dfsg-1) ...
Setting up libssh2-1:amd64 (1.7.0-1) ...
Setting up krb5-locales (1.15-1+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Setting up publicsuffix (20171028.2055-0+deb9u1) ...
Setting up libunistring0:amd64 (0.9.6+really0.9.3-0.1) ...
Setting up xz-utils (5.2.2-1.2+b1) ...
update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/lzma.1.gz because associated file /usr/share/man/man1/xz.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/unlzma.1.gz because associated file /usr/share/man/man1/unxz.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzcat.1.gz because associated file /usr/share/man/man1/xzcat.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzmore.1.gz because associated file /usr/share/man/man1/xzmore.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzless.1.gz because associated file /usr/share/man/man1/xzless.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzdiff.1.gz because associated file /usr/share/man/man1/xzdiff.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzcmp.1.gz because associated file /usr/share/man/man1/xzcmp.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzgrep.1.gz because associated file /usr/share/man/man1/xzgrep.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzegrep.1.gz because associated file /usr/share/man/man1/xzegrep.1.gz (of link group lzma) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/lzfgrep.1.gz because associated file /usr/share/man/man1/xzfgrep.1.gz (of link group lzma) doesn't exist
Setting up openssl (1.1.0f-3+deb9u1) ...
Setting up libsqlite3-0:amd64 (3.16.2-5+deb9u1) ...
Setting up libffi6:amd64 (3.2.1-6) ...
Setting up libkeyutils1:amd64 (1.5.9-9) ...
Setting up libsasl2-modules:amd64 (2.1.27~101-g0780600+dfsg-3) ...
Setting up ca-certificates (20161130+nmu1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Updating certificates in /etc/ssl/certs...
166 added, 0 removed; done.
Setting up libpython2.7-stdlib:amd64 (2.7.13-2+deb9u2) ...
Setting up libidn11:amd64 (1.33-1) ...
Setting up libidn2-0:amd64 (0.16-1+deb9u1) ...
Setting up libpsl5:amd64 (0.17.0-3) ...
Setting up python2.7 (2.7.13-2+deb9u2) ...
Setting up file (1:5.30-1+deb9u1) ...
Setting up libkrb5support0:amd64 (1.15-1+deb9u1) ...
Setting up libhogweed4:amd64 (3.3-1+b2) ...
Setting up libpython-stdlib:amd64 (2.7.13-2) ...
Setting up libp11-kit0:amd64 (0.23.3-2) ...
Setting up python (2.7.13-2) ...
Setting up libk5crypto3:amd64 (1.15-1+deb9u1) ...
Setting up libgnutls30:amd64 (3.5.8-5+deb9u3) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1+b1) ...
Setting up libldap-2.4-2:amd64 (2.4.44+dfsg-5+deb9u1) ...
Setting up libkrb5-3:amd64 (1.15-1+deb9u1) ...
Setting up libgssapi-krb5-2:amd64 (1.15-1+deb9u1) ...
Setting up libcurl3:amd64 (7.52.1-5+deb9u4) ...
Setting up libcurl3-gnutls:amd64 (7.52.1-5+deb9u4) ...
Setting up gnupg1-curl (1.4.21-4) ...
Setting up apt-transport-https (1.4.8) ...
Setting up curl (7.52.1-5+deb9u4) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for ca-certificates (20161130+nmu1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
The command '/bin/sh -c apt-get update     && apt-get install -qqy curl python apt-transport-https apt-utils gnupg1 procps     && echo 'deb https://packages.amplify.nginx.com/debian/ stretch amplify-agent' > /etc/apt/sources.list.d/nginx-amplify.list     && curl -fs https://nginx.org/keys/nginx_signing.key | apt-key add - > /dev/null 2>&1     && apt-get update     && apt-get install -qqy nginx-amplify-agent     && apt-get purge -qqy curl apt-transport-https apt-utils gnupg1     && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 2

Is it possible to log to docker logs?

Hello, I'm running this container in production, but it's a bit tricky to view its logs to troubleshoot an issue.

I use a platform-as-a-service (Digital Ocean App Platform, which is similar to Heroku), which streams the results of docker logs to a web interface. Unfortunately this doesn't show anything with this container, like it does for the official nginx image. Similarly, if I were to SSH into my server and run docker logs I wouldn't see the logs. I'd have to attach to the container and tail the access.log and error.log.

The official nginx image creates a symbolic link from /var/log/nginx/access.log to /dev/stdout, and creates another symbolic link from /var/log/nginx/error.log to /dev/stderr, which allows docker to output its logs without nginx knowing. This amplify image undoes this, assumedly so the python agent can access the log files asynchronously.

This sounds like an issue most users of this docker image have faced. Any suggestions for how to stream the logs to docker logs?

Nginx already started

When running the docker container I see messages like this:

2017/11/04 08:40:13 [emerg] 11#11: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/11/04 08:40:13 [emerg] 11#11: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/11/04 08:40:13 [emerg] 11#11: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/11/04 08:40:13 [emerg] 11#11: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/11/04 08:40:13 [emerg] 11#11: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/11/04 08:40:13 [emerg] 11#11: still could not bind()

Looks like Nginx is already started by the image that it depends on.

Unable to collect metrics for PHP-FPM running in a separate container without nginx

I'm running two docker containers, one for nginx (as a reverse proxy) and another with just php-fpm.

I am running the amplify agent in both containers but php-fpm metrics are not available in the php-fpm container.

amplify_missing_metrics

I'm assuming it has something to do with needing the presence of an nginx process as evidenced by these logs.

2020-09-04 10:16:48,061 [290200] supervisor phpfpm objects ['5d42ce21f39c859f69769bb01ce4f54324ec5e469c4e8237c40d4b8f503b38a1']
2020-09-04 10:16:48,062 [290200] supervisor phpfpm_pool objects: []
2020-09-04 10:16:49,388 [290200] phpfpm_metrics 5d42ce21f39c859f69769bb01ce4f54324ec5e469c4e8237c40d4b8f503b38a1 collect in 0.000
2020-09-04 10:16:50,196 [290200] sys_metrics f746575ef89e9f0229cad256576d0bbf88420a26f07ddf868b431dd2c722e509 collect in 0.007
2020-09-04 10:16:53,064 [290200] supervisor system objects: ['f746575ef89e9f0229cad256576d0bbf88420a26f07ddf868b431dd2c722e509']
2020-09-04 10:16:53,072 [290200] supervisor failed to find running nginx via ps xao pid,ppid,command | grep 'nginx[:]'
2020-09-04 10:16:53,073 [290200] supervisor additional info:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/amplify/agent/managers/nginx.py", line 218, in _find_all
    ps, _ = subp.call(ps_cmd)
  File "/usr/lib/python2.7/dist-packages/amplify/agent/common/util/subp.py", line 32, in call
    raise AmplifySubprocessError(message=command, payload=dict(returncode=process.returncode, error=raw_err))

Is there a way to collect PHP-FPM metrics when it's running in a separate container from nginx?

alpine build

Could not find a version that satisfies the requirement cffi!=1.11.3,>=1.8 (from versions: ) No matching distribution found for cffi!=1.11.3,>=1.8

Ubuntu 18.04.2 LTS

Unable reload NGINX use docker kill -s HUP

Hi,

how do you reload configuration in this container?

I try:
docker kill -s HUP <container-name>
docker exec <container-name> nginx -s reload

>docker exec <container-name> bash
container-shell>kill -1 `cat /run/nginx.pid`

But any not reload configuration

agent will fail to detect nginx, ps(1) is restricted!

I ran the install script inside my ngix container.
Triaged a few issues the docs forget to mention but finally completed install.
Only remaining error its:

agent will fail to detect nginx, ps(1) is restricted!

the logs show the agent started and connecting
the web site indeed shows that the agent failed to detect nginx.

the base container is the default nginx:latest from docker hub (i just attached a shell and ran the commands to install).

Nginx access log file size

Hello!

First of all, thank you for the image and documentation. I look forward to using Amplify on my Nginx Docker deployments.

I have a question regarding the Nginx log files. The README tells us to stop forwarding the log files and instead keep them in the container, so Amplify can parse the relevant data from them. My concern is that these logs may grow quite big and eventually fill up the entire disk.

Does the official Nginx image (or Amplify itself) automatically rotate these log files so they don't explode? If not, what steps would you recommend taking to deal with this?

Thank you!

Redundant command line parameter

Current instructions to run Amplify image are:

docker run --name mynginx1 -e API_KEY=ecfdee2e010899135c258d741a6effc7 -d nginx-amplify

After #2 is fixed, then -e API_KEY may not be required since the key is specified in the Dockerfile.

Build Error

Hi there

I'm not able to build either image today
docker build -t nginx-amplify .
errors with the following...

4.231 Processing triggers for libc-bin (2.36-9+deb12u1) ...
4.358   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
4.358                                  Dload  Upload   Total   Spent    Left  Speed
100  1561  100  1561    0     0   9532      0 --:--:-- --:--:-- --:--:--  9576
4.586 Hit:1 http://deb.debian.org/debian bookworm InRelease
4.596 Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
4.610 Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
5.250 Ign:4 https://packages.amplify.nginx.com/py3/debian bookworm InRelease
5.407 Err:5 https://packages.amplify.nginx.com/py3/debian bookworm Release
5.407   404  Not Found [IP: 52.24.43.197 443]
5.414 Reading package lists...
5.922 E: The repository 'https://packages.amplify.nginx.com/py3/debian bookworm Release' does not have a Release file.

The alpine version fails with this error

image

Dockerfile for alpine?

Hi,
is it possible to build this image with nginx:alpine?
Would be nice if you could provide the Dockerfile to do that.

separate agent and nginx containers

Running 2 separate services in the same container is much less than ideal. Why is there not a way yet to run this in a separate container, volume in logs, and have it talk to the status page on a separate nginx container?
I'd expect more from nginx here. the alpine Dockerfile, especially, is awful.

Build fails

Building the Docker image fails:

docker-nginx-amplify > docker build -t nginx-amplify .
Sending build context to Docker daemon 127.5 kB
Step 1 : FROM nginx:latest
 ---> 0d409d33b27e
Step 2 : MAINTAINER NGINX Amplify Engineering
 ---> Running in 18b98c3e4d6d
 ---> d8e91099e601
Removing intermediate container 18b98c3e4d6d
Step 3 : RUN apt-get update     && apt-get install -qqy curl python apt-transport-https apt-utils     && echo 'deb https://packages.amplify.nginx.com/debian/ jessie amplify-agent' > /etc/apt/sources.list.d/nginx-amplify.list     && curl -fs https://nginx.org/keys/nginx_signing.key | apt-key add - > /dev/null 2>&1     && apt-get update     && apt-get install -qqy nginx-amplify-agent     && apt-get purge -qqy curl apt-transport-https apt-utils     && rm -rf /var/lib/apt/lists/*
 ---> Running in 320478d4f475
Err http://nginx.org jessie InRelease

Err http://nginx.org jessie Release.gpg
  Could not resolve 'nginx.org'
Err http://httpredir.debian.org jessie InRelease

Err http://httpredir.debian.org jessie-updates InRelease

Err http://security.debian.org jessie/updates InRelease

Err http://httpredir.debian.org jessie Release.gpg
  Could not resolve 'httpredir.debian.org'
Err http://security.debian.org jessie/updates Release.gpg
  Could not resolve 'security.debian.org'
Err http://httpredir.debian.org jessie-updates Release.gpg
  Could not resolve 'httpredir.debian.org'
Reading package lists...
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/InRelease  

W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/InRelease  

W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease  

W: Failed to fetch http://nginx.org/packages/mainline/debian/dists/jessie/InRelease  

W: Failed to fetch http://nginx.org/packages/mainline/debian/dists/jessie/Release.gpg  Could not resolve 'nginx.org'

W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/Release.gpg  Could not resolve 'httpredir.debian.org'

W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/Release.gpg  Could not resolve 'httpredir.debian.org'

W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg  Could not resolve 'security.debian.org'

W: Some index files failed to download. They have been ignored, or old ones used instead.
E: Unable to locate package curl
E: Unable to locate package python
E: Unable to locate package apt-transport-https
E: Package 'apt-utils' has no installation candidate
The command '/bin/sh -c apt-get update     && apt-get install -qqy curl python apt-transport-https apt-utils     && echo 'deb https://packages.amplify.nginx.com/debian/ jessie amplify-agent' > /etc/apt/sources.list.d/nginx-amplify.list     && curl -fs https://nginx.org/keys/nginx_signing.key | apt-key add - > /dev/null 2>&1     && apt-get update     && apt-get install -qqy nginx-amplify-agent     && apt-get purge -qqy curl apt-transport-https apt-utils     && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

Pre built image

Just wondering why there isn't a pre built image available to pull in through docker? As far as I can tell there nothing preventing this ?

Can't run container

Hi, I'm trying to use Amplify and followed the README on how to create the container and run the image. Unfortunately, the container exist immediately and the only information from the logs are is standard_init_linux.go:185: exec user process caused "no such file or directory".

$ docker run --name mynginx1 -e API_KEY=$API_KEY -e AMPLIFY_IMAGENAME=my-service-123 -d agilys/nginx-amplify
bb1a37c524cec1f67580c1a34910495f610b625632f6c02548f847e3d47e2d50
$ docker ps -a
CONTAINER ID        IMAGE                  COMMAND             CREATED             STATUS                     PORTS               NAMES
bb1a37c524ce        agilys/nginx-amplify   "/entrypoint.sh"    10 seconds ago      Exited (1) 8 seconds ago                       mynginx1
$ docker logs mynginx1
standard_init_linux.go:185: exec user process caused "no such file or directory"

Any help on how to solve this? I built the image from the current master branch.

Regards,
Fabian

Build fails

Launching amplify-agent ...

Couldn't start the agent, please check /var/log/amplify-agent/agent.log

Work around:

# Install the Amplify Agent
RUN curl -L -o amplify-install.temp.sh \
    https://github.com/nginxinc/nginx-amplify-agent/raw/master/packages/install.sh && \
    head -n -12 amplify-install.temp.sh > amplify-install.sh && \
    rm amplify-install.temp.sh && \
    sh ./amplify-install.sh && \
    rm -f ./amplify-install.sh

Alpine docker

Hello,

I am using custom php alpine docker image. Spend half day trying to make the install-source.sh to work. In the end it looked like it did install. After i run the start command. Yet the dashboard is not detecting it. Do you have any working examples of working alpine dockerfiles?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.