Hey everyone, I'm looking for advice on logging performance queries for AWS Aurora databases, especially in contexts involving sensitive information, like personal or payment card data. I usually enable logging features such as "slow_query_log" for MySQL or "log_min_duration_statement" for PostgreSQL to analyze long-running queries and track performance issues. These logs help us set up alerts and fix potential problems.
However, in industries like finance, there are strict regulations around protecting sensitive data, and I'm worried that enabling such logging might inadvertently expose private information embedded in SQL queries.
How can I implement logging features while ensuring we stay compliant and avoid revealing sensitive data? It's crucial given the size of organizations where many developers and support teams are running queries around the clock. Any advice or best practices would be greatly appreciated!
2 Answers
In regulated environments, it's often recommended to turn off the 'log_min_duration_statement' option due to compliance concerns. Both Tenable and DataDog suggest this because of the sensitive nature of the data that could appear in logs.
If logging is necessary for troubleshooting, consider methods for scrubbing sensitive information from logs. This is especially true for application logs, which may also touch upon PII.
Additionally, carefully assess the practicality of slow query logging at cloud scale; it can create massive log volumes that may not provide much value. Instead, profiling queries before they go into production and monitoring latency directly can be far more efficient. It’s also beneficial to leverage performance insights to identify and resolve database issues without exposing private data.
And what about using MySQL's query digest feature? It redacts sensitive info. Can we push those to CloudWatch without breaching regulations?
I’d recommend following a generic approach for handling this kind of data. Here’s a simple step-by-step:
1) Enable slow query log exports from RDS to CloudWatch Logs.
2) Create a data protection policy for your CloudWatch log group.
3) Use custom data identifiers to mask any sensitive information as it's logged.
For specific guidelines, check out this AWS blog on handling sensitive log data. It provides some actionable insights on maintaining compliance while logging query performance.
Great tips! CloudWatch has some excellent features for managing sensitive data.
Thanks for the links! They could really help clarify the process.

Absolutely! Query tuning can be overkill; focusing on performance insights first is a solid approach.