Bin Log (Tail Log) in Google Cloud Spanner

474 Views Asked by At

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

There are 2 best solutions below

6
Chris32 On

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
Kristen Kozak On

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