You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在New Relic的APM模块中查看完整数据库查询语句?

How to View Full SQL Queries in New Relic APM's Databases Page

Hey there! I’ve dealt with this exact issue before when working with New Relic’s PHP APM, so let me break down the steps to get those full query statements visible:

1. Adjust Your New Relic PHP Agent Configuration

The most common reason you’re only seeing simplified <table name> select entries is because the agent limits SQL recording by default. Here’s how to update it:

  • Locate your New Relic PHP agent config file (usually newrelic.ini, or embedded in your main php.ini file)
  • Find the setting newrelic.transaction_tracer.record_sql and set it to one of these values:
    • raw: Records the full, unmodified SQL query (note: this includes parameter values, so be cautious with sensitive data like passwords or PII)
    • obfuscated: Keeps the full query structure but replaces sensitive parameter values with placeholders (like ?), balancing visibility and security
  • Save the config file, then restart your web server (Apache/Nginx) and PHP-FPM (if you’re using it) to apply the changes

2. Check the Individual Query Details Page

Even if the list view shows the simplified query, the full version might already be available in the details view:

  • On the Databases page, click on the <table name> select entry you want to inspect
  • In the query details page, look for a section labeled Full SQL or Obfuscated SQL (depending on your config) — this should display the complete query structure

3. Verify Transaction Tracer Settings

Make sure transaction tracing is enabled to capture detailed query data:

  • In your agent config, confirm newrelic.transaction_tracer.enabled = true
  • Adjust newrelic.transaction_tracer.threshold if needed (this sets the minimum duration for a transaction to be traced; setting it to a lower value like 0.5 ensures more queries are captured)

Once you’ve updated the config and restarted your services, give it a few minutes for New Relic to ingest the new data, and you should start seeing full query statements in either the details view or the main list (depending on your settings).


内容的提问来源于stack exchange,提问作者littleibex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:02:50