Conversation
7b4c4be to
72ad6c8
Compare
rfay
left a comment
There was a problem hiding this comment.
Nice setup, and I know it's been useful for you.
I wasn't successful getting it going by just following the instructions. It's been a number of years since I've used newrelic, so don't even remember what it's best for. Like blackfire?
Anyway, I guess I need more coaching to get it going. I tried with php7.4. Oh... there's a bug. You used PHP_DEFAULT_VERSION instead of DDEV_PHP_VERSION
| There are two configuration items in `docker-compose.newrelic.yaml`. | ||
|
|
||
| * `NEW_RELIC_LICENSE_KEY`: You must specify your license key. | ||
| * `NEW_RELIC_AGENT_VERSION`: Specify the New Relic agent version. |
There was a problem hiding this comment.
It seems that NEW_RELIC_AGENT_VERSION is specified, and not actually a configuration item? Or at least we can use it as-is for now, because it's wired in elsewhere.
| RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/${NEW_RELIC_LICENSE_KEY}/" \ | ||
| -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"${NEW_RELIC_APPNAME}\"/" \ | ||
| /etc/php/${PHP_DEFAULT_VERSION}/fpm/conf.d/newrelic.ini | ||
| RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/${NEW_RELIC_LICENSE_KEY}/" \ | ||
| -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"${NEW_RELIC_APPNAME}\"/" \ | ||
| /etc/php/${PHP_DEFAULT_VERSION}/cli/conf.d/newrelic.ini |
There was a problem hiding this comment.
Why not just put the newrelic.ini in .ddev/php ? It's easy to capture it using your technique , use docker cp to grab it. Instructions would have to change to have them change the appname there in the .ddev/php/newrelic.ini
There was a problem hiding this comment.
The technique used here copies only into /etc/php/${PHP_DEFAULT_VERSION}//conf.d - which means (currently) /etc/php/7.3//conf.d. But we might want php7.4 or something else.
We can't use DDEV_PHP_VERSION here because it's determined at container start time.
So that makes the previous suggestion more important. If you just put it in .ddev/php, it will go in the right place.
Alternately, copy into all the places (5.6/7.0/7.1/7.2/7.3/7.4/8.0) (I don't think 8.0 works yet?)
| ARG NEW_RELIC_LICENSE_KEY | ||
| ARG NEW_RELIC_APPNAME | ||
|
|
||
| RUN curl -L https://download.newrelic.com/php_agent/archive/${NEW_RELIC_AGENT_VERSION}/newrelic-php5-${NEW_RELIC_AGENT_VERSION}-linux.tar.gz | tar -C /tmp -zx \ |
There was a problem hiding this comment.
I note that this looks cleaner to do with DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5 and perhaps using the technique in https://docs.newrelic.com/docs/agents/php-agent/installation/php-agent-installation-ubuntu-debian - it still requires a Dockerfile because of the custom repo though.
| newrelic: | ||
| image: newrelic/php-daemon | ||
| container_name: ddev-${DDEV_SITENAME}-newrelic | ||
| ports: ['31339'] |
There was a problem hiding this comment.
I'm getting to where I like expose a lot more than ports these days, because a statement like this just does an expose and exposes an ephemeral port that's hard to find out.
| NEW_RELIC_LICENSE_KEY: "" | ||
| NEW_RELIC_APPNAME: ${DDEV_SITENAME} | ||
| links: | ||
| - newrelic |
There was a problem hiding this comment.
Shouldn't this be
| - newrelic | |
| - newrelic:newrelic |
Maybe they're the same.
| There are two configuration items in `docker-compose.newrelic.yaml`. | ||
|
|
||
| * `NEW_RELIC_LICENSE_KEY`: You must specify your license key. | ||
| * `NEW_RELIC_AGENT_VERSION`: Specify the New Relic agent version. |
There was a problem hiding this comment.
This kind of ends abruptly. Now what do you do when you've done these things? What do I have to set up on NewRelic? How do I know if it's working?
| RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/${NEW_RELIC_LICENSE_KEY}/" \ | ||
| -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"${NEW_RELIC_APPNAME}\"/" \ | ||
| /etc/php/${PHP_DEFAULT_VERSION}/fpm/conf.d/newrelic.ini | ||
| RUN sed -i -e "s/REPLACE_WITH_REAL_KEY/${NEW_RELIC_LICENSE_KEY}/" \ | ||
| -e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\"${NEW_RELIC_APPNAME}\"/" \ | ||
| /etc/php/${PHP_DEFAULT_VERSION}/cli/conf.d/newrelic.ini |
There was a problem hiding this comment.
The technique used here copies only into /etc/php/${PHP_DEFAULT_VERSION}//conf.d - which means (currently) /etc/php/7.3//conf.d. But we might want php7.4 or something else.
We can't use DDEV_PHP_VERSION here because it's determined at container start time.
So that makes the previous suggestion more important. If you just put it in .ddev/php, it will go in the right place.
Alternately, copy into all the places (5.6/7.0/7.1/7.2/7.3/7.4/8.0) (I don't think 8.0 works yet?)
|
I unfortunately tried this on a Drupal 9 project, so when I switched to PHP7.3 it failed. But then I tried on a D8 project, finally found some data that I didn't know how to use on Dashboards->Browser |
|
Thanks for the review @rfay, I've got this on my list to update |
|
Looking forward to seeing this get in @mglaman - thanks for the contribution! |
|
I'm sure this will be useful to people, so hope you can return to it. |
|
@mglaman you have lots to do, but please push this up to the top of your priority list and get it finished, thanks! |
|
It's been more than a year @mglaman - maybe you can fit this in with your 20% if you get it! |
|
@mglaman I would love to see this finished! |
|
Het @mglaman, I know it's been a long time, maybe you can help us on how to configure this service, thank you very much in advance |
|
Hello everyone, I have an example that is working decently, I'm not sure if it's the recommended way to do it. I have tried to follow the comments left by @rfay . I'm not an expert in Docker, so if you see any improvements, feel free to add them, and perhaps this recipe can become available.
version: '3.6'
services:
newrelic:
image: newrelic/php-daemon
container_name: ddev-${DDEV_SITENAME}-newrelic
ports: ['31339']
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT
web:
environment:
IMAGE_NAME: newrelic/php-daemon
NEW_RELIC_AGENT_VERSION: "9.2.0.247"
NEW_RELIC_LICENSE_KEY: "YOUR_API_KEY_HERE"
NEW_RELIC_APPNAME: ${DDEV_SITENAME}
NEW_RELIC_DAEMON_ADDRESS: "newrelic:31339"
links:
- newrelic:$DDEV_HOSTNAME
[newrelic]
newrelic.license = "YOUR_API_KEY_HERE"
newrelic.appname = "THE_SAME_NAME_OF_NEW_RELIC_APPNAME_VAR"
newrelic.distributed_tracing_enabled = true
newrelic.transaction_tracer.enabled = true
newrelic.application_logging.enabled = true
newrelic.application_logging.metrics.enabled = true
newrelic.application_logging.forwarding.enabled = true
FROM $BASE_IMAGE
ARG NEW_RELIC_AGENT_VERSION
ARG NEW_RELIC_LICENSE_KEY
ARG NEW_RELIC_APPNAME
RUN wget -O - https://download.newrelic.com/548C16BF.gpg | apt-key add - && \
sh -c 'echo "deb http://apt.newrelic.com/debian/ newrelic non-free" > /etc/apt/sources.list.d/newrelic.list' && \
apt-get update
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5
Run |
|
@Gonzalo2683 you're doing great! Could you please create an add-on that implements this? It's super easy, and that's the maintainable way to handle these recipes.
I'm sure that after you do that (use a good README) then @tyler36 and I will be happy to try it out and offer suggestions/issues/PRs to your repo. |
|
Is there a way to run this on Apple M2 ARM64? Any installation guide or commands would helpful, thanks. |
|
It looks like newrelic does not provide an arm64 image, https://hub.docker.com/r/newrelic/php-daemon/tags, even 3+ years after arm64 has arrived. |

Fixes #102