New Relic数据库慢查询无法显示带实际参数的SQL语句求助
Hey there! Let's work through this issue together since you're new to New Relic and trying to capture slow SQL queries with their actual parameters for your Kinto setup connected to PostgreSQL. Here are the key steps to check:
Double-check your kinto.ini configuration
First, make sure thetransaction_tracer.record_sql = rawsetting is placed correctly under the[newrelic]section of your kinto.ini file. Typos or wrong section placement are super easy to miss! Also, don't forget to restart your Kinto service after making configuration changes—this is a common oversight that keeps new settings from kicking in.Verify New Relic Agent Compatibility & Version
Since Kinto is a Python application, you're using the New Relic Python agent. Ensure you're running a recent, stable version of the agent—older versions might have limitations on capturing raw SQL with parameters. Also, confirm that you have the necessary PostgreSQL driver (like psycopg2) installed, as the agent relies on this to intercept database calls.Check Transaction Tracer Prerequisites
Raw SQL recording won't work if transaction tracing itself is disabled. Make sure you havetransaction_tracer.enabled = truein your New Relic config. Additionally, check thetransaction_tracer.thresholdvalue—this determines how slow a query needs to be to get recorded. If your "slow" queries don't meet this threshold, they won't show up. Try temporarily setting it to0.1(100ms) to test if you can capture queries with parameters.Confirm You're Looking in the Right Place in New Relic
It's easy to navigate to the wrong section! Raw SQL with parameters should appear under:- Transactions → Select the specific Kinto transaction → Databases tab
- Or Database → Query analysis
Also, make sure you're viewing data collected after you updated your configuration—old data won't reflect the new settings.
Rule Out Obfuscation or Middleware Interference
Check if New Relic's SQL obfuscation is accidentally enabled—this replaces parameters with?. Ensuretransaction_tracer.obfuscate_sql = falseis set in your config. Additionally, verify that Kinto itself isn't doing any parameter masking that would prevent the agent from capturing the actual values (though the agent intercepts at the driver level, so this is less likely).
内容的提问来源于stack exchange,提问作者Dhairya

