Data access logs for Firestore are disabled by default. You need to explicitly enable them to receive logs.
On the other hand, you're querying logs wrongly as you're missing projects/
before PROJECT_ID
, as explained here. Therefore, you should use:
logName=(
"projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fdata_access"
OR "projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Factivity"
OR "projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event"
OR "projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fpolicy")
You could also query logs from methodName. For instance, everytime you create a new Collection or Field in Firestore, Write
method will be used and logged. Thus, you could perform queries as:
protoPayload.methodName="google.firestore.v1.Firestore.Write"
Edit: Information about Delete operation logs as requested by @Troglo
You can see logs for every deletion done on Fields, Documents and Collections under the Write method, as it holds information on every write operation, such as delete. However, querying by methodName="google.firestore.v1.Firestore.Write"
will output all write operations done so far.
Alternatively, you could use the request
object to build a query as it holds information about Write fields, as update
or delete
. Therefore:
Deletion logs for any collection under your project
protoPayload.request.writes.delete:"projects/[PROJECT-ID]/databases/(default)/documents/"
Deletion logs for a specific collection
protoPayload.request.writes.delete:"projects/[PROJECT-ID]/databases/(default)/documents/[COLLECTION-ID]"
Notice the use of :
("has", matches any substring) instead of =
(equal) to build queries. The first one has a lower performance compared to the latter.
Important:
Please bear in mind that, as per today (26 October, 2021), these Data Access audit logs are in preview. Please, check the conditions and stage description for more information.