I have a managed MySQL instance on GCP. Where would I find a query log? Is this something I need to enable first somewhere? I have read their documentation ( https://cloud.google.com/sql/docs/mysql/how-to ) and didn't find it helpful on this topic.
1 Answer
It's all documented here and here.
Relevant part:
To make your general or slow query logs available, enable the corresponding flag and set the log_output flag to FILE. This makes the log output available using the Logs Viewer in the Google Cloud Platform Console. Note that Stackdriver logging charges apply.
If log_output is set to NONE, you will not be able to access the logs. If you set log_output to TABLE, the log output is placed in a table in your database. If this table becomes large, it can affect instance restart time or cause the instance to lose its SLA coverage; for this reason, the TABLE option is not recommended. If needed, you can truncate your log tables by using the API. For more information, see the instances.truncateLog reference page.
-
Thank you - ours is set to FILE, working on getting permissions to view logs in Stackdriver now! Commented Apr 18, 2019 at 19:47
-
After setting this up, I am only able to view error and activity logs - not query logs. Any more tips? Commented Apr 23, 2019 at 13:38
-
-
Yes, but I am interested in ALL queries, not just the slow ones... the slow queries portion is working OK. Commented Apr 23, 2019 at 14:36
-
2
SHOW VARIABLES LIKE %log%
or similar and that should point you to any logs you have that are operational. p.s. welcome to the forum!:-)