Firebase Realtime Database audit logging

This page describes the audit logs created by Firebase as part of Cloud Audit Logs.


Firebase services write audit logs to help you answer the questions, "Who did what, where, and when?". These are Cloud Audit Logs, provided as part of the Google Cloud project connected to your Firebase project.

Your Firebase projects each contain only the audit logs for resources that are directly within the project.

For a general overview of Cloud Audit Logs, see Cloud Audit Logs overview. For a deeper understanding of the audit log format, see Understand audit logs.

Available audit logs

The following types of audit logs are available for Firebase Realtime Database:

  • Admin Activity audit logs

    Includes "admin write" operations that write metadata or configuration information.

    You can't disable Admin Activity audit logs.

  • Data Access audit logs

    Includes "admin read" operations that read metadata or configuration information. Also includes "data read" and "data write" operations that read or write user-provided data.

    To receive Data Access audit logs, you must explicitly enable them.

For fuller descriptions of the audit log types, see Types of audit logs.

Audited operations

The following summarizes which API operations correspond to each audit log type in Firebase Realtime Database:

Audit logs category Firebase Realtime Database operations
Admin Activity Audit Logs (ADMIN_WRITE)
  • CreateDatabaseInstance
  • DeleteDatabaseInstance
  • DisableDatabaseInstance
  • ReenableDatabaseInstance
Data Access Audit Logs (ADMIN_READ)
  • GetDatabaseInstance
  • ListDatabaseInstances
Data Access Audit Logs (DATA_READ or DATA_WRITE)
  • Connect
  • Disconnect
  • RunOnDisconnect
  • Update (with Precondition) (for transaction operations). See associated Precondition and WriteMetadata.
Data Access Audit Logs (DATA_READ)
Data Access Audit Logs (DATA_WRITE)
  • Write
  • Update. See associated WriteMetadata.
  • OnDisconnectPut
  • OnDisconnectUpdate. See associated WriteMetadata.
  • OnDisconnectCancel

Audit authentication information

Audit log entries include information about the identity that performed the logged operation. To identify a request caller, see the following fields within the AuditLog object:

  • Establishing realtime connections. Realtime Database Connect operations do not log authentication data since Realtime Database authenticates after a connection is established. Therefore, Connect has no authentication info. The AuthenticationInfo object contains a placeholder principalEmail of audit-pending-auth@firebasedatabase-{REGION_CODE}

  • Google Authentication. Realtime Database operations that use standard Google Authentication, such as traffic from Firebase Admin SDK or REST requests authenticated with a standard OAuth token, have an AuthenticationInfo object that contains the actual credentials email.

  • Firebase Authentication. Realtime Database operations that use Firebase Authentication have an AuthenticationInfo object that contains a principalEmail value of audit-third-party-auth@firebasedatabase-{REGION_CODE} The same is true if you implement your own authentication solution by minting custom JWTs.

    • If a JSON Web Token (JWT) was used for third-party authentication, the thirdPartyPrincipal field includes the token's header and payload. For example, audit logs for requests authenticated with Firebase Authentication include that request's Firebase Authentication token.
  • No authentication. Realtime Database operations that do not use any authentication have an AuthenticationInfo object that contains a principalEmail value of audit-no-auth@firebasedatabase-{REGION_CODE} A Realtime Database instance with open security rules may grant such requests. We recommend all users secure their databases properly.

  • Legacy secrets tokens. Realtime Database operations using legacy tokens have an AuthenticationInfo object that contains a placeholder principalEmail of audit-secret-auth@firebasedatabase-{REGION_CODE} For secrets-signed JWT, thirdPartyPrincipal contains the JWT headers and payload.

Audit Firebase Security Rules evaluations

Cloud Audit logs can be used to identify requests that will be potentially affected by Rules changes.

In the AuthorizationInfo object, authorization.permission can be one of:

  • Read access granted at the path specified in resource.
  • Write access granted at the path specified in resource.
  • Placeholder for Connect and Disconnect. No authorization required to connect to a Realtime Database instance.
  • Used for Unlisten and OnDisconnectCancel. Revoking or canceling a previously-authorized operation requires no additional authorization.

Correlate Cloud Audit logs with Realtime Database profiler results

You can perform in-depth performance analysis on Realtime Database using the Realtime Database profiler in combination with Realtime Database audit logging. Each tool has its strengths.

Cloud Audit Logging Realtime Database profiler
  • Audits access to databases
  • Continuously captures all requests
  • Allows retrospective querying
  • Contains detailed auth token info
  • Incurs a usage cost
  • Used for performance analysis
  • Provides useful tooling for hotspot identification and thus performance optimization
  • Can measure listener-broadcast, which is not available in Audit logs due to potential data volume
  • Lightweight and realtime, making it good for live load testing. Audit log entries may take a few minutes to appear.

Audit log contents correspond to profiler metrics as shown below.

Audit Logging operation name Special values in
Profiler operation name
Connect RequestType is REALTIME concurrent-connect
Disconnect RequestType is REALTIME concurrent-disconnect
Read RequestType is REALTIME realtime-read
Read RequestType is REST rest-read
Write RequestType is REALTIME realtime-write
Write RequestType is REST rest-write
Update RequestType is REALTIME.
Check PreconditionType.
Update RequestType is REST.
Check PreconditionType.
ListenerListen RequestType is REALTIME listener-listen
ListenerUnlisten RequestType is REALTIME listener-unlisten
OnDisconnectPut RequestType is REALTIME on-disconnect-put
OnDisconnectUpdate RequestType is REALTIME on-disconnect-update
OnDisconnectCancel RequestType is REALTIME on-disconnect-cancel
RunOnDisconnect RequestType is REALTIME run-on-disconnect

Audit log format

Audit log entries include the following objects:

  • The log entry itself, which is an object of type LogEntry. Useful fields include the following:

    • The logName contains the resource ID and audit log type.
    • The resource contains the target of the audited operation.
    • The timestamp contains the time of the audited operation.
    • The protoPayload contains the audited information.
  • The audit logging data, which is an AuditLog object held in the protoPayload field of the log entry.

  • Optional service-specific audit information, which is a service-specific object. For older integrations, this object is held in the serviceData field of the AuditLog object; newer integrations use the metadata field.

For other fields in these objects, and how to interpret them, review Understand audit logs.

Additional information about fields in protoPayload.metadata for DATA_READ and DATA_WRITEoperations is available in the reference documentation.

Log name

Cloud Audit Logs resource names indicate the Firebase project or other Google Cloud entity that owns the audit logs, and whether the log contains Admin Activity, Data Access, Policy Denied, or System Event audit logging data. For example, the following shows log names for project-level Admin Activity audit logs and an organization's Data Access audit logs. The variables denote Firebase project and organization identifiers.


Service name

Firebase Realtime Database audit logs use the service name

For a full list of all the Cloud Logging API service names and their corresponding monitored resource type, see Map services to resources.

Resource types

Firebase Realtime Database audit logs use the resource type audited_resource for all audit logs.

For a list of all the Cloud Logging monitored resource types and descriptive information, see Monitored resource types.

Enable audit logging

Admin Activity audit logs are always enabled; you can't disable them.

Data Access audit logs are disabled by default and aren't written unless explicitly enabled (the exception is Data Access audit logs for BigQuery, which can't be disabled).

Data Access audit logs for Realtime Database are toggled by checking DATA_READ and/or DATA_WRITE in the GCP Console. There is up to a one hour delay between the time that logs are enabled/disabled in the GCP Console and the time that logs start/stop being delivered.

For instructions on enabling some or all of your Data Access audit logs, see Configure Data Access logs.

Permissions and roles

Cloud IAM permissions and roles determine your ability to access audit logs data in Google Cloud resources.

When deciding which Logging-specific permissions and roles apply to your use case, consider the following:

  • The Logs Viewer role (roles/logging.viewer) gives you read-only access to Admin Activity, Policy Denied, and System Event audit logs. If you have just this role, you cannot view Data Access audit logs that are in the _Default bucket.

  • The Private Logs Viewer role(roles/logging.privateLogViewer) includes the permissions contained in roles/logging.viewer, plus the ability to read Data Access audit logs in the _Default bucket.

    Note that if these private logs are stored in user-defined buckets, then any user who has permissions to read logs in those buckets can read the private logs. For more information on log buckets, see Routing and storage overview.

For more information on the Cloud IAM permissions and roles that apply to audit logs data, see Access control.

View logs

To find and view audit logs, you need to know the identifier of the Firebase project, folder, or organization for which you want to view audit logging information. You can further specify other indexed LogEntry fields, like resource.type; for details, review Find log entries quickly.

The following are the audit log names; they include variables for the identifiers of the Firebase project, folder, or organization:




You can view audit logs in Cloud Logging using the GCP Console, the gcloud command-line tool, or the Logging API.


You can use the Logs Explorer in the GCP Console to retrieve your audit log entries for your Firebase project, folder, or organization:

  1. In the GCP Console, go to the Logging > Logs Explorer page.

    Go to the Logs Explorer page

  2. On the Logs Explorer page, select an existing Firebase project, folder or organization.

  3. In the Query builder pane, do the following:

    • In Resource type, select the Google Cloud resource whose audit logs you want to see.

    • In Log name, select the audit log type that you want to see:

      • For Admin Activity audit logs, select activity.
      • For Data Access audit logs, select data_access.
      • For System Event audit logs, select system_event.
      • For Policy Denied audit logs, select policy.

    If you don't see these options, then there aren't any audit logs of that type available in the Firebase project, folder, or organization.

    For more details about querying using the Logs Explorer, see Build log queries.


The gcloud command-line tool provides a command-line interface to the Cloud Logging API. Supply a valid PROJECT_ID, FOLDER_ID, or ORGANIZATION_ID in each of the log names.

To read your Firebase project-level audit log entries, run the following command:

gcloud logging read "logName : projects/PROJECT_ID/logs/" --project=PROJECT_ID

To read your folder-level audit log entries, run the following command:

gcloud logging read "logName : folders/FOLDER_ID/logs/" --folder=FOLDER_ID

To read your organization-level audit log entries, run the following command:

gcloud logging read "logName : organizations/ORGANIZATION_ID/logs/" --organization=ORGANIZATION_ID

For more information about using the gcloud tool, see Read log entries.


When building your queries, replace the variables with valid values, substitute the appropriate project-level, folder-level, or organization-level audit log name or identifiers as listed in the audit log names. For example, if your query includes a PROJECT_ID, then the project identifier you supply must refer to the currently selected Firebase project.

To use the Logging API to look at your audit log entries, do the following:

  1. Go to the Try this API section in the documentation for the entries.list method.

  2. Put the following into the Request body part of the Try this API form. Clicking on this prepopulated form automatically fills the request body, but you need to supply a valid PROJECT_ID in each of the log names.

      "resourceNames": [
      "pageSize": 5,
      "filter": "logName : projects/PROJECT_ID/logs/"
  3. Click Execute.

For more details about querying, see Logging query language.

For an example of an audit log entry and how to find the most important information in it, see Sample audit log entry.

Route audit logs

You can route audit logs to supported destinations in the same way that you can route other kinds of logs. Here are some reasons you might want to route your audit logs:

  • To keep audit logs for a longer period of time or to use more powerful search capabilities, you can route copies of your audit logs to Google Cloud Storage, BigQuery, or Google Cloud Pub/Sub. Using Cloud Pub/Sub, you can route to other applications, other repositories, and to third parties.

  • To manage your audit logs across an entire organization, you can create aggregated sinks that can route logs from any or all Firebase projects in the organization.

  • If your enabled Data Access audit logs are pushing your Firebase projects over your log allotments, you can create sinks that exclude the Data Access audit logs from Logging.

For instructions on routing logs, see Configure sinks.


Admin Activity audit logs and System Event audit logs are no-cost.

Data Access audit logs and Policy Denied audit logs are chargeable.

For more information about Cloud Logging pricing, see Google Cloud's operations suite pricing: Cloud Logging.