0
votes

Can we get bin log of DML statements execution in Google Cloud Spanner. Tried enabling "Data Access Write" Logs, but it does not give the same bin log as mysql or other relational databases.

https://cloud.google.com/spanner/docs/audit-logging

https://cloud.google.com/logging/docs/audit/configure-data-access

https://console.cloud.google.com/iam-admin/audit?_ga=2.231523607.908127545.1587027457-1147786289.1577266273

2
Data access write logs should now have dml statements in the protoPayload.request.sql field for ExecuteSql and ExecuteStreamingSql calls. Could you check and see if your queries are there? For the streaming queries, you'll see two log entries per query, one marking start and another marking end -- they will have matching operation.id fields, the start entry will have operation.first set to true; the request field is only in the start log entry. - Ozan Bellik

2 Answers

0
votes

Cloud Spanner doesnt include a build in utility to generate binlogs like MySQL. You will have to implement your own change log table to keep track of the changes.

You can also make use of the Audit logs to keep track of Who is performing the changes. So using both the Audit logs and your own change log table would be the ideal solution to track your changes.

0
votes

Data access audit logs for ExecuteSql and ExecuteStreamingSql contain the SQL statement, so you can produce a log of DML statements by enabling “Data Write” audit logs for “Cloud Spanner API”, as described in https://cloud.google.com/logging/docs/audit/configure-data-access#config-console-enable:

enabling data write audit logs

The SQL statement is contained in the single log entry generated for ExecuteSql or the first log entry generated for ExecuteStreamingSql, in the field protoPayload.request.sql. For example, here are the log entries generated for an ExecuteStreamingSql request:

example audit logs for an ExecuteStreamingSql request