From 12fbe201aef2ffebba809e223460f5bf3dc9b445 Mon Sep 17 00:00:00 2001
From: Konstantin Pavlov <thresh@nginx.com>
Date: Fri, 27 Oct 2017 17:21:34 -0400
Subject: [PATCH] Removed amplify agent.

---
 generate-stackbrew-library.sh            |  17 --
 mainline/amplify/Dockerfile              |  80 ---------
 mainline/amplify/README.md               | 207 -----------------------
 mainline/amplify/conf.d/stub_status.conf |   9 -
 mainline/amplify/entrypoint.sh           |  77 ---------
 5 files changed, 390 deletions(-)
 delete mode 100644 mainline/amplify/Dockerfile
 delete mode 100644 mainline/amplify/README.md
 delete mode 100644 mainline/amplify/conf.d/stub_status.conf
 delete mode 100755 mainline/amplify/entrypoint.sh

diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh
index a2acd48..73418f8 100755
--- a/generate-stackbrew-library.sh
+++ b/generate-stackbrew-library.sh
@@ -101,21 +101,4 @@ for version in "${versions[@]}"; do
 		EOE
 	done
 
-	for variant in amplify; do
-        if [ "$version" == "stable" ]; then
-               continue
-        fi
-		commit="$(dirCommit "$version/$variant")"
-
-		variantAliases=( "${versionAliases[@]/%/-$variant}" )
-		variantAliases=( "${variantAliases[@]//latest-/}" )
-
-		echo
-		cat <<-EOE
-			Tags: $(join ', ' "${variantAliases[@]}")
-			GitCommit: $commit
-			Directory: $version/$variant
-		EOE
-	done
-
 done
diff --git a/mainline/amplify/Dockerfile b/mainline/amplify/Dockerfile
deleted file mode 100644
index f020604..0000000
--- a/mainline/amplify/Dockerfile
+++ /dev/null
@@ -1,80 +0,0 @@
-FROM debian:stretch-slim
-
-LABEL maintainer="NGINX Amplify Engineering"
-
-ENV NGINX_VERSION         1.13.6-1~stretch
-ENV NJS_VERSION           1.13.6.0.1.14-1~stretch
-ENV AMPLIFY_AGENT_VERSION 0.46-2~stretch
-
-RUN set -x \
-    && deps="apt-transport-https apt-utils gnupg1 ca-certificates" \
-    && apt-get update \
-    && apt-get install --no-install-recommends --no-install-suggests -y $deps \
-    && echo "deb https://packages.amplify.nginx.com/debian/ stretch amplify-agent" > /etc/apt/sources.list.d/nginx-amplify.list \
-    && echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list.d/nginx.list \
-    && \
-    NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
-    found=''; \
-    for server in \
-        ha.pool.sks-keyservers.net \
-        hkp://keyserver.ubuntu.com:80 \
-        hkp://p80.pool.sks-keyservers.net:80 \
-        pgp.mit.edu \
-    ; do \
-        echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
-        apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
-    done; \
-    test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
-    apt-get update \
-    && nginxPackages=" \
-        nginx=${NGINX_VERSION} \
-        nginx-module-xslt=${NGINX_VERSION} \
-        nginx-module-geoip=${NGINX_VERSION} \
-        nginx-module-image-filter=${NGINX_VERSION} \
-        nginx-module-njs=${NJS_VERSION} \
-        nginx-amplify-agent=${AMPLIFY_AGENT_VERSION} \
-    " \
-    && apt-get install --no-install-recommends --no-install-suggests -y \
-        $nginxPackages \
-        gettext-base \
-        procps \
-    && apt-get remove --purge --auto-remove -y $deps \
-    && rm -rf /etc/apt/sources.list.d/nginx-amplify.list \
-    && rm -rf /etc/apt/sources.list.d/nginx-amplify.list \
-    && rm -rf /var/lib/apt/lists/*
-
-# Copy nginx stub_status config
-COPY ./conf.d/stub_status.conf /etc/nginx/conf.d
-
-# API_KEY is required for configuring the NGINX Amplify Agent.
-# It could be your real API key for NGINX Amplify here if you wanted
-# to build your own image to host it in a private registry.
-# However, including private keys in the Dockerfile is not recommended.
-# Use the environment variables at runtime as described below.
-
-#ENV API_KEY 1234567890
-
-# 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
-
-# The /entrypoint.sh script will launch nginx and the Amplify Agent.
-# The script honors API_KEY and AMPLIFY_IMAGENAME environment
-# variables, and updates /etc/amplify-agent/agent.conf accordingly.
-
-COPY ./entrypoint.sh /entrypoint.sh
-
-# TO set/override API_KEY and AMPLIFY_IMAGENAME when starting an instance:
-# docker run --name my-nginx1 -e API_KEY='..effc' -e AMPLIFY_IMAGENAME="service-name" -d nginx-amplify
-
-EXPOSE 80
-
-STOPSIGNAL SIGTERM
-
-ENTRYPOINT ["/entrypoint.sh"]
diff --git a/mainline/amplify/README.md b/mainline/amplify/README.md
deleted file mode 100644
index 3bc74cd..0000000
--- a/mainline/amplify/README.md
+++ /dev/null
@@ -1,207 +0,0 @@
-<!-- START doctoc generated TOC please keep comment here to allow auto update -->
-<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
-
-
-- [1. Overview](#1-overview)
-  - [1.1. NGINX Amplify Agent Inside Docker Container](#11-nginx-amplify-agent-inside-docker-container)
-  - [1.2. Standalone Mode](#12-standalone-mode)
-  - [1.3. Aggregate Mode](#13-aggregate-mode)
-  - [1.4. Current Limitations](#14-current-limitations)
-- [2. How to Build and Run an Amplify-enabled NGINX image?](#2-how-to-build-and-run-an-amplify-enabled-nginx-image)
-  - [2.1. Building an Amplify-enabled image with NGINX](#21-building-an-amplify-enabled-image-with-nginx)
-  - [2.2. Running an Amplify-enabled NGINX Docker Container](#22-running-an-amplify-enabled-nginx-docker-container)
-
-<!-- END doctoc generated TOC please keep comment here to allow auto update -->
-
-
-## 1. Overview
-
-[NGINX Amplify](https://amplify.nginx.com/signup/) 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](https://github.com/nginxinc/nginx-amplify-agent) should be installed inside the container.
-
-The official documentation for Amplify is available [here](https://github.com/nginxinc/nginx-amplify-doc/blob/master/amplify-guide.md).
-
-### 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](https://github.com/nginxinc/nginx-amplify-doc/blob/master/amplify-guide.md#changing-the-hostname-and-uuid) 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](https://github.com/nginxinc/nginx-amplify-doc/blob/master/amplify-guide.md#configuring-the-agent).
-
-### 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](https://github.com/nginxinc/nginx-amplify-doc/blob/master/amplify-guide.md#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](https://github.com/nginxinc/nginx-amplify-doc/blob/master/amplify-guide.md#configuring-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](https://docs.docker.com/engine/installation/) how to install Docker Engine on various OS.)
-
-Let's pick our official [NGINX Docker image](https://hub.docker.com/_/nginx/) as a good example. The Dockerfile that we're going to use for an Amplify-enabled image is [part of this repo](https://github.com/nginxinc/docker-nginx-amplify/blob/master/Dockerfile).
-
-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](https://amplify.nginx.com/signup/), 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.
diff --git a/mainline/amplify/conf.d/stub_status.conf b/mainline/amplify/conf.d/stub_status.conf
deleted file mode 100644
index e9bea0c..0000000
--- a/mainline/amplify/conf.d/stub_status.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-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;
-        }
-    }
diff --git a/mainline/amplify/entrypoint.sh b/mainline/amplify/entrypoint.sh
deleted file mode 100755
index 2b5afa8..0000000
--- a/mainline/amplify/entrypoint.sh
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/sh
-#
-# This script launches nginx and the NGINX Amplify Agent.
-#
-# Unless already baked in the image, a real API_KEY is required for the
-# NGINX Amplify Agent to be able to connect to the backend.
-#
-# If AMPLIFY_IMAGENAME is set, the 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 Amplify. Otherwise NGINX Amplify
-# will create separate objects for monitoring (an object per instance).
-#
-
-# Variables
-agent_conf_file="/etc/amplify-agent/agent.conf"
-agent_log_file="/var/log/amplify-agent/agent.log"
-nginx_status_conf="/etc/nginx/conf.d/stub_status.conf"
-api_key=""
-amplify_imagename=""
-
-# Launch nginx
-echo "starting nginx ..."
-nginx -g "daemon off;" &
-
-nginx_pid=$!
-
-test -n "${API_KEY}" && \
-    api_key=${API_KEY}
-
-test -n "${AMPLIFY_IMAGENAME}" && \
-    amplify_imagename=${AMPLIFY_IMAGENAME}
-
-if [ -n "${api_key}" -o -n "${amplify_imagename}" ]; then
-    echo "updating ${agent_conf_file} ..."
-
-    if [ ! -f "${agent_conf_file}" ]; then
-	test -f "${agent_conf_file}.default" && \
-	cp -p "${agent_conf_file}.default" "${agent_conf_file}" || \
-	{ echo "no ${agent_conf_file}.default found! exiting."; exit 1; }
-    fi
-
-    test -n "${api_key}" && \
-    echo " ---> using api_key = ${api_key}" && \
-    sh -c "sed -i.old -e 's/api_key.*$/api_key = $api_key/' \
-	${agent_conf_file}"
-
-    test -n "${amplify_imagename}" && \
-    echo " ---> using imagename = ${amplify_imagename}" && \
-    sh -c "sed -i.old -e 's/imagename.*$/imagename = $amplify_imagename/' \
-	${agent_conf_file}"
-
-    test -f "${agent_conf_file}" && \
-    chmod 644 ${agent_conf_file} && \
-    chown nginx ${agent_conf_file} > /dev/null 2>&1
-
-    test -f "${nginx_status_conf}" && \
-    chmod 644 ${nginx_status_conf} && \
-    chown nginx ${nginx_status_conf} > /dev/null 2>&1
-fi
-
-if ! grep '^api_key.*=[ ]*[[:alnum:]].*' ${agent_conf_file} > /dev/null 2>&1; then
-    echo "no api_key found in ${agent_conf_file}! exiting."
-fi
-
-echo "starting amplify-agent ..."
-service amplify-agent start > /dev/null 2>&1 < /dev/null
-
-if [ $? != 0 ]; then
-    echo "couldn't start the agent, please check ${agent_log_file}"
-    exit 1
-fi
-
-wait ${nginx_pid}
-
-echo "nginx master process has stopped, exiting."
-- 
GitLab