php - Get New Relic running in docker container

I'm trying to get New Relic running in a docker container (FROM php:7.3-apache
) to push up to Cloud Run.
I've followed this documentation
https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/docker-other-container-environments-install-php-agent/
For "Install agent and daemon in the same container" and added
RUN \
curl -L https://download.newrelic.com/php_agent/release/newrelic-php5-9.17.1.301-linux.tar.gz | tar -C /tmp -zx && \
export NR_INSTALL_USE_CP_NOT_LN=1 && \
export NR_INSTALL_SILENT=1 && \
/tmp/newrelic-php5-*/newrelic-install install && \
rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* && \
sed -i \
-e 's/"REPLACE_WITH_REAL_KEY"/"NRAK-xxxxxxxxxxxxxxxxxxx"/' \
-e 's/newrelic.appname = "PHP Application"/newrelic.appname = "My apps real name"/' \
-e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
-e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \
/usr/local/etc/php/conf.d/newrelic.ini
To my docker file and switched the 3 variables to real values.
When I do PS inside the container it looks like it's running but nothing is appearing in the New Relic dashboard.
When I cat out php_agent.log I get
2021-06-21 19:06:34.870 +0000 (1 1) info: attempt daemon connection via '@newrelic'
2021-06-21 19:06:34.871 +0000 (1 1) info: New Relic 9.17.1.301 ("xigua" - "6498785b65c7") [daemon='@newrelic' php='7.3.28' zts=no sapi='apache2handler' apache='2.4.38' mpm=prefork pid=1 ppid=0 uid=0 euid=0 gid=0 egid=0 backtrace=yes
startup=agent os='Linux' rel='4.19.128-microsoft-standard' mach='x86_64' ver='#1 SMP Tue Jun 23 12' node='544d6a6fd26a']
2021-06-21 19:06:34.871 +0000 (1 1) warning: A global default license has not been set or has invalid format. Please add a 'newrelic.license' key in the global php.ini or in the newrelic.ini file, or ensure that a valid license is provided on a per-virtual host or per-directory basis.
When I cat out newrelic-daemon.log I get
2021/06/21 19:06:34.974122 (17) Info: New Relic daemon version 9.17.1.301-6498785b65c7 [listen="@newrelic" startup=agent pid=17 ppid=1 uid=0 euid=0 gid=0 egid=0 runtime="go1.9.7" GOMAXPROCS=24 GOOS=linux GOARCH=amd64]
2021/06/21 19:06:35.024983 (36) Info: New Relic daemon version 9.17.1.301-6498785b65c7 [listen="@newrelic" startup=agent pid=36 ppid=17 uid=0 euid=0 gid=0 egid=0 runtime="go1.9.7" GOMAXPROCS=24 GOOS=linux GOARCH=amd64]
2021/06/21 19:06:35.071290 (53) Info: New Relic daemon version 9.17.1.301-6498785b65c7 [listen="@newrelic" startup=agent pid=53 ppid=36 uid=0 euid=0 gid=0 egid=0 runtime="go1.9.7" GOMAXPROCS=24 GOOS=linux GOARCH=amd64]
2021/06/21 19:06:35.071516 (53) Info: collector configuration is &{CAFile: CAPath: Proxy:}
2021/06/21 19:06:35.071855 (53) Info: daemon listening on @newrelic
php --ini
gives me
Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File: (none)
Scan for additional .ini files in: /usr/local/etc/php/conf.d
Additional .ini files parsed: /usr/local/etc/php/conf.d/docker-php-ext-imap.ini,
/usr/local/etc/php/conf.d/docker-php-ext-mysqli.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini,
/usr/local/etc/php/conf.d/newrelic.ini
When Icat /usr/local/etc/php/conf.d/newrelic.ini | grep "newrelic.license"
I get my real correct key
; Setting: newrelic.license
newrelic.license = "NRAK-xxxxxxxxxxxxxxxxxxxxx"
What am I doing wrong or what step have I missed?
Answer
Solution:
Your license key is wrong.
A global default license has not been set or has invalid format. Please add a 'newrelic.license' key in the global php.ini or in the newrelic.ini file, or ensure that a valid license is provided on a per-virtual host or per-directory basis.
It's appears that you are putting the user API_KEY: NRAK-xxxxxxxxxxxxxxxxxxxxx, but acctually you have to put your licence key found on Administration > API Keys > License Keys
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: undefined array key
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.