Giám sát cơ sở dữ liệu bằng Cloud Monitoring

Tài liệu này mô tả tính năng ghi nhật ký kiểm tra cho Cloud Firestore. Google Cloud tạo nhật ký kiểm tra để ghi lại các hoạt động quản trị và truy cập trong tài nguyên Google Cloud của bạn.

Để biết thêm thông tin về Nhật ký kiểm tra trên đám mây, hãy xem nội dung sau:

Ghi chú

Khi định cấu hình tính năng ghi nhật ký kiểm tra, hãy sử dụng tên dịch vụ datastore.googleapis.com để định cấu hình cả datastore.googleapis.com và firestore.googleapis.com. Once configured, logs for the Cloud Firestore API include the service namefirestore.googleapis.com`.

Để xem thời gian xử lý yêu cầu DATA_READ hoặc DATA_WRITE, hãy xem trường processing_duration trong đối tượng metadata của AuditLog. Trường processing_duration mô tả thời gian cơ sở dữ liệu cần để xử lý một yêu cầu. Độ trễ này nhỏ hơn độ trễ của người dùng cuối. Cụ thể, chỉ số này không bao gồm mức hao tổn mạng.

Tên dịch vụ

Nhật ký kiểm tra của Cloud Firestore sử dụng tên dịch vụ là firestore.googleapis.com. Bộ lọc cho dịch vụ này:

protoPayload.serviceName="firestore.googleapis.com"

Phương thức theo loại quyền

Mỗi quyền IAM đều có một thuộc tính type, có giá trị là một enum có thể là một trong bốn giá trị: ADMIN_READ, ADMIN_WRITE, DATA_READ hoặc DATA_WRITE. Khi bạn gọi một phương thức, Cloud Firestore sẽ tạo một nhật ký kiểm tra có danh mục phụ thuộc vào thuộc tính type của quyền cần thiết để thực hiện phương thức đó.

Các phương thức yêu cầu quyền IAM có giá trị thuộc tính type là DATA_READ, DATA_WRITE hoặc ADMIN_READ sẽ tạo nhật ký kiểm tra Truy cập dữ liệu.

Các phương thức yêu cầu quyền IAM có giá trị thuộc tính type là ADMIN_WRITE sẽ tạo nhật ký kiểm tra Hoạt động của quản trị viên.

Loại quyền Phương thức
ADMIN_READ google.cloud.location.Locations.GetLocation
google.cloud.location.Locations.ListLocations
google.firestore.admin.v1.FirestoreAdmin.GetBackup
google.firestore.admin.v1.FirestoreAdmin.GetBackupSchedule
google.firestore.admin.v1.FirestoreAdmin.GetDatabase
google.firestore.admin.v1.FirestoreAdmin.GetField
google.firestore.admin.v1.FirestoreAdmin.GetIndex
google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules
google.firestore.admin.v1.FirestoreAdmin.ListBackups
google.firestore.admin.v1.FirestoreAdmin.ListDatabases
google.firestore.admin.v1.FirestoreAdmin.ListFields
google.firestore.admin.v1.FirestoreAdmin.ListIndexes
google.firestore.admin.v1beta1.FirestoreAdmin.GetIndex
google.firestore.admin.v1.MongoDBCompatible.ListIndexes
google.firestore.admin.v1.MongoDBCompatible.ListDatabases
ADMIN_WRITE google.firestore.admin.v1.FirestoreAdmin.CreateBackupSchedule
google.firestore.admin.v1.FirestoreAdmin.CreateDatabase
google.firestore.admin.v1.FirestoreAdmin.CreateIndex
google.firestore.admin.v1.FirestoreAdmin.DeleteBackup
google.firestore.admin.v1.FirestoreAdmin.DeleteBackupSchedule
google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase
google.firestore.admin.v1.FirestoreAdmin.DeleteIndex
google.firestore.admin.v1.FirestoreAdmin.RestoreDatabase
google.firestore.admin.v1.FirestoreAdmin.UpdateBackupSchedule
google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase
google.firestore.admin.v1.FirestoreAdmin.UpdateField
google.longrunning.Operations.CancelOperation
google.longrunning.Operations.DeleteOperation
DATA_READ google.firestore.v1.MongoDBCompatible.Find
google.firestore.v1.MongoDBCompatible.Aggregate
google.firestore.v1.MongoDBCompatible.GetMore
google.firestore.v1.MongoDBCompatible.ListCollections
google.firestore.v1.MongoDBCompatible.Count
google.firestore.v1.MongoDBCompatible.Distinct
google.firestore.v1.MongoDBCompatible.CommitTransaction
google.firestore.v1.MongoDBCompatible.AbortTransaction
google.firestore.v1.MongoDBCompatible.EndSessions
google.firestore.v1.MongoDBCompatible.KillCursors
DATA_WRITE google.firestore.v1.MongoDBCompatible.Insert
google.firestore.v1.MongoDBCompatible.Update
google.firestore.v1.MongoDBCompatible.Delete
google.firestore.v1.MongoDBCompatible.FindAndModify
google.firestore.v1.MongoDBCompatible.CreateCollection

Xác định phương thức gọi yêu cầu

Mục nhập Nhật ký kiểm tra bao gồm thông tin về danh tính đã thực hiện thao tác được ghi lại. Để xác định phương thức gọi yêu cầu, hãy xem các trường sau trong đối tượng AuditLog:

  • Danh tính của phương thức gọi được lưu giữ trong trường AuthenticationInfo. Thông tin này có thể bao gồm principalEmail của người dùng. Thông tin này đôi khi được biên tập lại.

  • Trường callerIp trong đối tượng requestMetadata của một mục nhập AuditLog bao gồm địa chỉ IP của phương thức gọi.