Monitor Php Cli docker containers

Is it possible to monitor php code running inside a php-cli docker container which runs specific php scripts and then terminates.
The php cli container is alive for a few seconds only.


Hi @zookal - The documentation suggests that you can install APM on a docker container running php.

I found this blog post on the cli configuration for New Relic

1 Like

Hey @zookal -

Let us know if Stefan’s comment was helpful - please do mark it as the solution if it did help you :smiley:

Hi stefan,
Thank you for the response.
I was able to install newrelic php agent in my container and it works for long running php containers, but it doesn’t work for containers which are short lived and terminate quickly after running one single php script.
I read some other articles and the only solution seems to be mentioned in the link below which isn’t ideal for us.

Thank you

1 Like


The information you mentioned is correct; if the container shuts down before the harvest cycle is complete, that data won’t be sent.

That sounds like a great Feature Idea for a configuration option to force the agent to send data on exit. If you have a moment, I’d suggest adding that as a PHP agent Feature Idea to bring this to the attention of our product team. Thanks!

Its not only about php-agent not sending data before the harvest cycle is complete. It seems New Relic agent also needs a few php calls to initiate and start sending data which isn’t ideal for containers running a single php script.

Along with the info shared in some of the threads linked here I wanted to share a new guide I’ve created for this issue with examples of how to resolve this issue: