מעקב אחרי מסדי נתונים באמצעות Cloud Monitoring

במאמר הזה מוסבר על רישום ביומני ביקורת במסגרת Cloud Firestore. שירותי Google Cloud יוצרים יומני ביקורת שבהם מתועדים אירועי גישה למשאבי Google Cloud ופעילויות אדמין שמבוצעות בהם.

אתם יכולים לקרוא מידע נוסף על יומני הביקורת של Cloud במאמרים האלה:

הערות

כשמגדירים רישום ביומן הביקורת, משתמשים בשם השירות datastore.googleapis.com כדי להגדיר גם את datastore.googleapis.com וגם את firestore.googleapis.com. Once configured, logs for the Cloud Firestore API include the service namefirestore.googleapis.com`.

כדי לראות כמה זמן לקח לעבד בקשת DATA_READ או DATA_WRITE, אפשר לעיין בשדה processing_duration באובייקט metadata של AuditLog. השדה processing_duration מתאר את משך הזמן שלקח למסד הנתונים לעבד בקשה. הזמן הזה קצר יותר מזמן האחזור של משתמש הקצה. באופן ספציפי, הוא לא כולל את התקורה של הרשת.

שם השירות

יומני הביקורת של Cloud Firestore משתמשים בשם השירות firestore.googleapis.com. אפשר לסנן לפי השירות הזה:

protoPayload.serviceName="firestore.googleapis.com"

קודי Method לפי סוג ההרשאה

לכל הרשאה ב-IAM יש מאפיין type עם enum שיכול להיות אחד מארבעת הערכים הבאים: ADMIN_READ,‏ ADMIN_WRITE,‏ DATA_READ או DATA_WRITE. כשקוראים ל-method, נוצר יומן ביקורת של Cloud Firestore שהקטגוריה שלו תלויה במאפיין type של ההרשאה שנדרשת לביצוע ה-method.

שיטות שדורשות הרשאת IAM עם ערך המאפיין type של DATA_READ,‏ DATA_WRITE או ADMIN_READ יוצרות יומני ביקורת של גישה לנתונים.

ב-methods שדורשות הרשאת IAM עם ערך המאפיין type של ADMIN_WRITE, נוצרים יומני ביקורת של פעילות אדמין.

סוג ההרשאה Methods
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

זיהוי המתקשרים שביקשו את השיחה

הרשומות ביומן הביקורת כוללות מידע על הזהות שביצעה את הפעולה שנרשמה ביומן. כדי לזהות את מבצע הקריאה החוזרת, אפשר לעיין בשדות הבאים באובייקט AuditLog:

  • זהות המתקשר מופיעה בשדה AuthenticationInfo. המידע הזה יכול לכלול את principalEmail של המשתמש. המידע הזה מצונזר לפעמים.

  • השדה callerIp באובייקט requestMetadata של רשומת AuditLog כולל את כתובת ה-IP של מבצע הקריאה.