如何在 New Relic 中查看完整查询

How to see full query in New Relic

当我转到 APM > 应用程序 > PHP 应用程序 > 数据库时,它会显示查询列表及其性能。但查询显示为 <table name> select。我怎样才能看到完整的查询?

如果您有 New Relic 的付费帐户,您将可以访问缓慢的 SQL 查询和交易跟踪;如果交易达到 apdex_f,这些将显示在 UI 中。

更多信息在这里: https://docs.newrelic.com/docs/apm/applications-menu/monitoring/view-slow-query-details

根据 https://docs.newrelic.com/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration#tx_tracer_config,您必须将 record_sql 配置设置为 'raw''obfuscated'。默认情况下它是 'off' 所以你不会看到 SQL.

请记住,这是在 transaction_tracer 部分中。因此,例如 Node.js(我知道你正在使用 PHP),你会这样做:

{
  transaction_tracer: {
    record_sql: 'raw',
  },
}