[PHP] New Relic PHP agent not capturing database queries

day

Modified today

Viewed 3 times

0

NewRelic not capturing database queries. Other queries are ok, that is a signal that the agent is running and everything is ok.

However, I can not see the database queries on the explorer, I just have the PHP agent.

Do I need the database agent running?

NewRelic not capturing database queries. Other queries are ok, that is a signal that the agent is running and everything is ok.

However, I can not see the database queries on the explorer, I just have the PHP agent.

Do I need the database agent running?

image

Hi @rodrigo.delduca

Thank you for reaching out, and welcome to the Explorers Hub.

I hope you are well.

I can see my that one of the other Community Moderators @JoiConverse has gone ahead and looped in the engineer team to help.

They should reach out here with their findings, should in the meantime you have any additional questions or updates, please do reach out!

1 Like

Hello @rodrigo.delduca ,

Database queries should be gathered via the PHP agent by default, as long as you are using one of the supported databases for the PHP agent, which can be seen in the following link:

You will also want to make sure you are using the latest version of the PHP agent, which at this time is 9.21.0.311. Lastly, you will want to check to make sure there are no active DENY-NEW-METRICS rules on the application, which you can see under Settings > Metric normalization

You had mentioned “other queries are ok” previously. Can you clarify which queries are reporting without issue, and what type of databases do you expect to report that are not currently?

You had mentioned “other queries are ok” previously. Can you clarify which queries are reporting without issue, and what type of databases do you expect to report that are not currently?

I mean, all other metrics are being collected, except the database one.

My site runs PHP and WordPress, I think NewRelic can collect the database metrics from WordPress, right?

Thank you

Hi @rodrigo.delduca

Sorry to hear you are still facing some challenges. While this area of PHP is a little complex, I wonder if this could be due to, how in rare cases, using Guzzle with WordPress and PHP 7.4 caused crashes. Which apparently was fixed with the most recent update of PHP.

Can you confirm you are using the most up to date version, see PHP agent v9.14.0.290 | New Relic Documentation.

Looking forward to hearing from you!

Hi @rodrigo.delduca

Let me get another PHP expert here to have a look from the engineering team. They will have a better scope here than I. Please note they will reach out via this post with their findings.

If you have any updates, fixes or questions please do reach out.

Hey there @rodrigo.delduca ,

Thanks for reaching out to the New Relic Community! I think I might be able to shed some light on your situation through these docs HERE
If you have any questions or extra details to add in the meantime, then please don’t hesitate to reach out.

Cheers

@eschwall just to confirm, the PHP agent will not collect the database queries?

Hi @rodrigo.delduca ,

To confirm, the PHP agent should absolutely be collecting your database queries, as this is a common functionality used by the majority of our PHP agent users. If you are not seeing database queries, then there is likely either a problem with the agent, a block in the UI, or you are using an unsupported database.

I mentioned in my last message to check if you have an active DENY-NEW-METRICS rule on this application. Can you confirm if this is indeed the case? And also, can you please clarify which database you are using that is missing (ex. MySQL, MariaDB, PostgreSQL, etc.)?

Hi @tlugo, thank you for your reply.

We use PHP 7.4, with the latest version of the NewRelic agent and the Database is the MariaDB, we run WooCommerce.

There is no DENY-NEW-METRICS.

Our variables

php_value[newrelic.enabled] = true
php_value[newrelic.license] = {{env "NEWRELIC_LICENSE"}}
php_value[newrelic.appname] = {{env "DOMAIN"}}
php_value[newrelic.browser_monitoring.auto_instrument] = false
php_value[newrelic.daemon.address] = 127.0.0.1:8136
php_value[newrelic.daemon.location] = /usr/bin/newrelic-daemon
php_value[newrelic.logfile] = /dev/null
php_value[newrelic.loglevel] = error

Our setup

set -eo pipefail

curl -L https://download.newrelic.com/php_agent/release/newrelic-php5-9.21.0.311-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*

echo "newrelic.browser_monitoring.auto_instrument = false" >>/etc/php/7.4/fpm/conf.d/newrelic.ini
echo "newrelic.daemon.address = 127.0.0.1:8136" >>/etc/php/7.4/fpm/conf.d/newrelic.ini
echo "newrelic.daemon.logfile = /dev/null" >>/etc/php/7.4/fpm/conf.d/newrelic.ini
echo "newrelic.logfile = /dev/null" >>/etc/php/7.4/fpm/conf.d/newrelic.ini
echo "newrelic.loglevel = error" >>/etc/php/7.4/fpm/conf.d/newrelic.ini
echo "newrelic.daemon.dont_launch = 3" >>/etc/php/7.4/fpm/conf.d/newrelic.ini
echo "newrelic.daemon.dont_launch = 3" >>/etc/newrelic/newrelic.cfg

We run the agent with the following command line

/usr/bin/newrelic-daemon --watchdog-foreground --logfile /dev/null -f --address=127.0.0.1:8136

Hey @rodrigo.delduca,

Thank you for the clarification. The team is still working on a solution for you and will follow up shortly. We appreciate your patience as we continue to provide support. Please let us know if anything else changes!

Hi @rodrigo.delduca ,

Thanks for that clarification! If that is the case, then it would make sense why you are not capturing database queries. MariaDB is not one of the databases that are currently supported by the PHP agent, as can be seen in the agent’s compatibility and requirements documentation. You can view this documentation at the following link:

You would still be able to instrument your MariaDB queries, but it would require some extra instrumentation from your end. You can use the PHP agent’s API to extend upon the data that is gathered by default. In your case, you would want to use the newrelic_record_datastore_segment API call. This would allow for an unsupported datastore to be instrumented in the same way as the PHP agent automatically instruments its supported datastores listed in the documentation above.

For more information on the newrelic_record_datastore_segment API call, please see the following link: