Docker Community Forums

Share and learn in the Docker community.

Enabling nginx-nr-agent


(Jdasinger) #1

I’m having an issue enabling the nginx-nr-agent (newrelic nginx plugin) on top of the official nginx container. The container builds fine but only starts and runs the nginx-nr-agent, but not the nginx process itself. The agent seems to be configured correctly as the logs show it trying to poll the nginx status page but since the nginx process isn’t running it just says it can’t connect. Relevant docker-compose and Dockerfile pasted below.

Docker-compose

webapp:
build: .
ports:
- 3000
environment:
- PORT=3000
- NODE_ENV=production

nginx:
build: ./docker/nginx
ports:
- 80:80
links:
- webapp
tty: true

Dockerfile:

FROM nginx:latest

COPY nginx.conf /etc/nginx/nginx.conf

RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
&& echo “deb http://nginx.org/packages/mainline/debian/ jessie nginx” >> /etc/apt/sources.list
&& apt-get update
&& apt-get install --no-install-recommends --no-install-suggests -y
nginx-nr-agent
&& rm -rf /var/lib/apt/lists/*

COPY nginx-nr-agent.ini /etc/nginx-nr-agent/nginx-nr-agent.ini

CMD [“nginx-nr-agent.py”, “-f”, “start”]

Would appreciate being pointed in the right direction or to some relevant documentation.

Thanks!
J


(Jeff Anderson) #2

It looks like your image is specifically starting nginx-nr-agent.py as the pid1 of this container. This overrides the default CMD, which starts nginx as the pid1 of the container.

There are a few approaches you could take. You could run something else as the pid1 (like maybe supervisor or runit) that is in turn configured to run both nginx and nginx-nr-agent.py.

Another possibility might be to run nginx-nr-agent in its own container. I don’t know enough about how it works to know for certain that is an option. If it is trying to connect to nginx, that suggests that it may be runnable as a separate container.


(Jdasinger) #3

Hi Jeff!

Thanks for your reply!

I modified my docker-compose and created a new Dockerfile to run the agent in a separate container.

nginx-nr-agent:
build: ./docker/nginx-nr-agent
links:
- nginx
tty: true

FROM debian:jessie

RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
&& echo “deb http://nginx.org/packages/mainline/debian/ jessie nginx” >> /etc/apt/sources.list
&& apt-get update
&& apt-get install --no-install-recommends --no-install-suggests -y
nginx-nr-agent
&& rm -rf /var/lib/apt/lists/*

COPY nginx-nr-agent.ini /etc/nginx-nr-agent/nginx-nr-agent.ini

CMD [“nginx-nr-agent.py”, “-f”, “start”]

EXPOSE 80 443

This container built correctly and the newrelic agent container is able to successfully poll the nginx container according to the logs. But I’m getting some kind of SSL error that seems to be keeping the agent from forwarding the collected stats to NewRelic itself.

nginx-nr-agent_1 | 2016-04-27 21:06:25,951 nginx-nr-agent [INFO]: using configuration from /etc/nginx-nr-agent/nginx-nr-agent.ini nginx_1 | 172.17.0.4 - - [27/Apr/2016:21:06:25 +0000] "GET /basic_status HTTP/1.1" 200 97 "-" "Python-urllib/2.7" nginx-nr-agent_1 | 2016-04-27 21:06:25,953 nginx-nr-agent [INFO]: starting with 1 configured data sources, poll_interval=60 nginx-nr-agent_1 | 2016-04-27 21:06:25,953 nginx-nr-agent [INFO]: polling source1 nginx-nr-agent_1 | 2016-04-27 21:06:25,954 nginx-nr-agent [DEBUG]: getting data from http://nginx/basic_status (lastupdate=0.000) nginx-nr-agent_1 | 2016-04-27 21:06:25,958 nginx-nr-agent [DEBUG]: processing stub status for express nginx-nr-agent_1 | 2016-04-27 21:06:25,960 nginx-nr-agent [DEBUG]: update gauge conn/active: rv=1.00 nginx-nr-agent_1 | 2016-04-27 21:06:25,960 nginx-nr-agent [DEBUG]: update gauge conn/idle: rv=0.00 nginx-nr-agent_1 | 2016-04-27 21:06:25,961 nginx-nr-agent [DEBUG]: update gauge reqs/current: rv=1.00 nginx-nr-agent_1 | 2016-04-27 21:06:25,961 nginx-nr-agent [INFO]: polling source1 finished successfully nginx-nr-agent_1 | 2016-04-27 21:06:25,962 nginx-nr-agent [DEBUG]: composing push data for express (3 entries) nginx-nr-agent_1 | 2016-04-27 21:06:25,962 nginx-nr-agent [INFO]: pushing 5 metrics for 1 components nginx-nr-agent_1 | 2016-04-27 21:06:25,963 nginx-nr-agent [DEBUG]: JSON payload: '{"components": [{"duration": 60, "metrics": {"Component/Connections/Active[Connections]": 1, "Component/Connections/Idle[Connections]": 0, "Component/ConnSummary/Idle[Connections]": 0, "Component/Requests/Current[Requests]": 1, "Component/ConnSummary/Active[Connections]": 1}, "guid": "com.nginx.newrelic-agent", "name": "express"}], "agent": {"version": "2.0.0"}}' nginx-nr-agent_1 | 2016-04-27 21:06:26,036 nginx-nr-agent [ERROR]: POST request for https://platform-api.newrelic.com/platform/v1/metrics failed: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

Am I missing some kind of network configuration in my Dockerfile that’s needed for this to work or is the issue likely with the plugin?